forked from pannous/english-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
error_test.rb
executable file
·83 lines (67 loc) · 1.75 KB
/
error_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
#!/usr/bin/env ruby
# HERE NOT encoding: utf-8
$use_tree=false
$verbose =false
# $verbose=true
require_relative '../parser_test_helper'
class ErrorTest < ParserBaseTest
include ParserTestHelper
def test_type #todo
assert_has_error "x=1,2,y;" # at:3y= in:list type:unknownVariable:y
end
def test_variable_type_safety_errors2
assert_has_no_error "char i='c'"
assert_has_no_error "char i;i='c'"
end
def test_variable_type_safety_errors
assert_has_no_error "an integer i;i=3"
assert_has_no_error "int i=3"
assert_has_no_error "int i;i=3"
assert_has_error "const i=1;i=2"
assert_has_error "string i=3" # idea: hack 3.to_s
assert_has_error "int i='hi'"
assert_has_error "integer i='hi'"
assert_has_error "an integer i;i='hi'"
assert_has_error "const i=1;i='hi'"
assert_has_error "const i='hi';i='ho'"
end
def test_assert_has_error
begin
assert_has_no_error "dfsafdsa ewdfsa}{P}{P;@#%"
rescue
assert_has_error "dfsafdsa ewdfsa}{P}{P;@#%"
puts "OK, HAS ERROR"
end
end
def test_type3
assert_has_error "x be 1,2,3y= class of x" # at:3y= in:list
end
def test_map
assert_has_error("square 1,2 andy 3") # at:andy in:list
end
def test_x
parse "x"
end
def test_endNode_as
init "as"
@parser.arg rescue
assert_has_error "as"
end
def test_rollback
assert_has_error('if 1>0 then else');
end
def test_endNode
# init "of"
# @parser.word
assert_has_error "of"
end
def test_list_concatenation_unknownVariable
variables['x']='hi'
variables['y']='world'
assert_has_error "z=x ' ' w"
skip #todo
assert "z=x ' ' y"
assert_has_error "z=x ' ' y" #tdod NOO
assert_has_no_error "z=x ' ' y" #setter OK!?!
end
end