forked from pannous/english-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
future_test.rb
executable file
·88 lines (69 loc) · 2.07 KB
/
future_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env ruby
# require 'test_helper'
$use_tree=false
# $use_tree=true
require_relative '../parser_test_helper'
# TESTS in this class are NOT meant to pass yet,
# they can be read as a to do list,
# to play with or
# to be pasted to other test classes
class FutureTest # < ParserBaseTest
include ParserTestHelper
def dont_yet_test_false_returns
assert_result_is "if 1<2 then false else 4",:false
assert_result_is "if 1<2 then false else 4",false
end
def test_if_statement
init 'if x is smaller than three then everything is fine;'
@parser.if_then
assert_equals variables['everything'], 'fine'
parse 'x=2;if x is smaller than three then everything is good;'
puts variables["everything"]
assert_equals variables['everything'], 'good'
# parse "x=2;if x is smaller than three everything is fine;" 'then' keyword needed! (why?)
# assert "everything is fine"
end
def test_repeat_until
parse 'repeat until x>4: x++'
assert_equals variables["x"], 5
end
def test_try_until
parse 'try until x>4: x++'
assert_equals variables["x"], 5
parse 'try while x<4: x++'
assert_equals variables["x"], 4
parse "try x++ until x>4"
assert_equals variables["x"], 5
parse "try x++ while x<4"
assert_equals variables["x"], 4
parse 'increase x until x>4'
assert_equals variables["x"], 5
end
def test_property_setter
parse "new circle;circle.color=green"
assert_equals("circle.color","green")
end
def test_local_variables_changed_by_subblocks
parse "x=2;def test\nx=1\nend\ntest"
init "x=2 or x=1"
assert @parser.condition_tree
assert "x=2"
parse "x=1;x=2;"
assert "x=2"
parse "x=1;while x<2 do x=2;"
assert "x=2"
# parse "x=1;try x=2;"
# assert "x=2"
end
# (beep three) times
def test_loops #OK
parse 'beep three times' #OK
parse "repeat three times: beep; okay" #OK
parse "repeat three times: beep" #OK
end
def test_action_n_times
parse "2 times say 'hello'"
parse "say 'hello' 2 times"
parse "puts 'hello' 2 times"
end
end