[python] Add tests for each module

This commit is contained in:
Émilie Feral
2020-04-01 15:41:48 +02:00
committed by LeaNumworks
parent ec5803f06f
commit cdff61f64b
7 changed files with 139 additions and 0 deletions

38
python/test/turtle.cpp Normal file
View File

@@ -0,0 +1,38 @@
#include <quiz.h>
#include "execution_environment.h"
// TODO: to be completed
QUIZ_CASE(python_turtle) {
TestExecutionEnvironment env = init_environement();
assert_command_execution_fails(env, "forward(3)");
assert_command_execution_succeeds(env, "from turtle import *");
assert_command_execution_succeeds(env, "reset()");
assert_command_execution_succeeds(env, "forward(10)");
assert_command_execution_succeeds(env, "backward(5)");
assert_command_execution_succeeds(env, "right(10)");
assert_command_execution_succeeds(env, "left(5)");
assert_command_execution_succeeds(env, "circle(28)");
assert_command_execution_succeeds(env, "speed(28)");
assert_command_execution_succeeds(env, "goto(28,28)");
assert_command_execution_succeeds(env, "position()", "(28.0, 28.0)\n");
assert_command_execution_succeeds(env, "setheading(28)");
assert_command_execution_succeeds(env, "heading()", "28.0\n");
assert_command_execution_succeeds(env, "pendown()");
assert_command_execution_succeeds(env, "penup()");
assert_command_execution_succeeds(env, "pensize(2)");
assert_command_execution_succeeds(env, "isdown()", "False\n");
assert_command_execution_succeeds(env, "showturtle()");
deinit_environment();
}
QUIZ_CASE(python_turtle_circle) {
// Turtle position should be unchanged after a complete circle
TestExecutionEnvironment env = init_environement();
assert_command_execution_succeeds(env, "from turtle import *");
assert_command_execution_succeeds(env, "goto(0,0)");
assert_command_execution_succeeds(env, "circle(28)");
// FIXME: this is actually not true
//assert_command_execution_succeeds(env, "position()", "(0.0, 0.0)\n");
deinit_environment();
}