[python] Test: add all template scripts

This commit is contained in:
Émilie Feral
2020-04-01 14:20:41 +02:00
committed by LeaNumworks
parent 11dc259566
commit ffb8f8f953
5 changed files with 20 additions and 24 deletions

13
python/test/basics.cpp Normal file
View File

@@ -0,0 +1,13 @@
#include <quiz.h>
#include "execution_environment.h"
QUIZ_CASE(python_basics) {
assert_command_execution_succeeds("2+3","5\n");
}
QUIZ_CASE(python_template) {
assert_script_execution_succeeds(Code::ScriptTemplate::Squares()->content());
assert_script_execution_succeeds(Code::ScriptTemplate::Mandelbrot()->content());
assert_script_execution_succeeds(Code::ScriptTemplate::Polynomial()->content());
assert_script_execution_succeeds(Code::ScriptTemplate::Parabola()->content());
}

View File

@@ -1,21 +0,0 @@
#include <quiz.h>
#include "execution_environment.h"
static const char * s_mandelbrotScript = R"(#
def mandelbrot(N_iteration):
for x in range(320):
for y in range(222):
z = complex(0,0)
c = complex(3.5*x/319-2.5, -2.5*y/221+1.25)
i = 0
while (i < N_iteration) and abs(z) < 2:
i = i + 1
z = z*z+c
rgb = int(255*i/N_iteration)
col = (int(rgb),int(rgb*0.75),int(rgb*0.25))
mandelbrot(2)
)";
QUIZ_CASE(python_mandelbrot) {
assert_script_execution_succeeds(s_mandelbrotScript);
}