Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
general
stups
prob-teaching-notebooks
Commits
e82f08a2
Commit
e82f08a2
authored
Nov 23, 2020
by
Chris
Browse files
Name Shadowing beendet
parent
35f66707
Changes
2
Hide whitespace changes
Inline
Side-by-side
info4/kapitel-8/Interpreter/test_loop_interpreter.py
View file @
e82f08a2
...
...
@@ -234,15 +234,15 @@ class LOOPInterpreterTest(unittest.TestCase):
self
.
assertEqual
(
interpret
(
'x1:=x1-2;
\n
x0:=x1+2'
),
2
)
@
mock
.
patch
(
'loopinterpreter.input'
,
side_effect
=
input_exit
)
def
test_break_exit
(
self
,
input
):
def
test_break_exit
(
self
,
custom_
input
):
self
.
assertEqual
(
interpret
(
'x1:=2; BREAK x0:=2'
),
-
1
)
self
.
assertEqual
(
interpret
(
'LOOP x1 DO BREAK x2:= 2 END'
),
-
1
)
@
mock
.
patch
(
'loopinterpreter.input'
,
side_effect
=
input_continue
)
def
test_break_continue
(
self
,
input
):
def
test_break_continue
(
self
,
custom_
input
):
self
.
assertEqual
(
interpret
(
'x1:=2; LOOP x1 DO x0:=x0+2 BREAK END'
),
4
)
@
mock
.
patch
(
'lexer.Lexer.__init__'
,
init_without_tokens
)
def
test_unknown_tokens
(
self
):
with
self
.
assertRaises
(
SyntaxError
):
interpret
(
'BLIBLABLUB'
)
\ No newline at end of file
interpret
(
'BLIBLABLUB'
)
info4/kapitel-8/Interpreter/test_while_interpreter.py
View file @
e82f08a2
...
...
@@ -116,5 +116,5 @@ class WHILEInterpreterTest(LOOPInterpreterTest):
interpret
(
'WHILE x1 != 0 DO x0:=2;;x2:=1 END'
)
@
mock
.
patch
(
'whileinterpreter.input'
,
side_effect
=
str_yes
)
def
test_infinite_loop
(
self
,
input
):
def
test_infinite_loop
(
self
,
custom_
input
):
self
.
assertEqual
(
interpret
(
'x1:=100000; WHILE x1 != 0 DO x0:=1; x1:=x1-1 END'
,
1
),
-
1
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment