From ffb8f8f953d835e59434515eeec6a24deefd28e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Wed, 1 Apr 2020 14:20:41 +0200 Subject: [PATCH] [python] Test: add all template scripts --- apps/Makefile | 2 +- apps/code/Makefile | 6 +++++- python/Makefile | 2 +- python/test/basics.cpp | 13 +++++++++++++ python/test/mandelbrot.cpp | 21 --------------------- 5 files changed, 20 insertions(+), 24 deletions(-) create mode 100644 python/test/basics.cpp delete mode 100644 python/test/mandelbrot.cpp diff --git a/apps/Makefile b/apps/Makefile index c3af54608..dc9e4c63e 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -94,7 +94,7 @@ all_app_src = $(app_src)(apps_launch_on_boarding_src) $(apps_launch_default_src) $(call object_for,$(all_app_src)): $(BUILD_DIR)/apps/i18n.h $(call object_for,$(all_app_src)): $(BUILD_DIR)/python/port/genhdr/qstrdefs.generated.h -apps_tests_src = $(app_calculation_test_src) $(app_probability_test_src) $(app_regression_test_src) $(app_sequence_test_src) $(app_shared_test_src) $(app_statistics_test_src) $(app_settings_test_src) $(app_solver_test_src) +apps_tests_src = $(app_calculation_test_src) $(app_code_test_src) $(app_probability_test_src) $(app_regression_test_src) $(app_sequence_test_src) $(app_shared_test_src) $(app_statistics_test_src) $(app_settings_test_src) $(app_solver_test_src) apps_tests_src += $(addprefix apps/,\ global_preferences.cpp \ diff --git a/apps/code/Makefile b/apps/code/Makefile index f05354dff..33b60f68b 100644 --- a/apps/code/Makefile +++ b/apps/code/Makefile @@ -1,6 +1,10 @@ apps += Code::App app_headers += apps/code/app.h +app_code_test_src = $(addprefix apps/code/,\ + script_template.cpp \ +) + app_code_src = $(addprefix apps/code/,\ app.cpp \ console_controller.cpp \ @@ -19,10 +23,10 @@ app_code_src = $(addprefix apps/code/,\ script_node_cell.cpp \ script_parameter_controller.cpp \ script_store.cpp \ - script_template.cpp \ variable_box_controller.cpp \ ) +app_code_src += $(app_code_test_src) app_src += $(app_code_src) i18n_files += $(addprefix apps/code/,\ diff --git a/python/Makefile b/python/Makefile index 4c0a92323..cf3ed9764 100644 --- a/python/Makefile +++ b/python/Makefile @@ -189,7 +189,7 @@ $(eval $(call rule_for, \ $(call object_for,$(python_src)): $(BUILD_DIR)/python/port/genhdr/qstrdefs.generated.h tests_src += $(addprefix python/test/,\ + basics.cpp \ execution_environment.cpp \ - mandelbrot.cpp \ matplotlib.cpp \ ) diff --git a/python/test/basics.cpp b/python/test/basics.cpp new file mode 100644 index 000000000..937b0023f --- /dev/null +++ b/python/test/basics.cpp @@ -0,0 +1,13 @@ +#include +#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()); +} diff --git a/python/test/mandelbrot.cpp b/python/test/mandelbrot.cpp deleted file mode 100644 index 0c59bbfa8..000000000 --- a/python/test/mandelbrot.cpp +++ /dev/null @@ -1,21 +0,0 @@ -#include -#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); -}