-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathfailing_tests.rb
140 lines (116 loc) · 2.95 KB
/
failing_tests.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
GC.disable
#include 'mruby/test/assert.rb'
assert('GC.enable') do
assert_false GC.disable
assert_true GC.enable
assert_false GC.enable
end
assert('GC.disable') do
begin
assert_false GC.disable
assert_true GC.disable
ensure
GC.enable
end
end
assert('GC.interval_ratio=') do
origin = GC.interval_ratio
begin
assert_equal 150, (GC.interval_ratio = 150)
ensure
GC.interval_ratio = origin
end
end
assert('GC.step_ratio=') do
origin = GC.step_ratio
begin
assert_equal 150, (GC.step_ratio = 150)
ensure
GC.step_ratio = origin
end
end
assert('GC.generational_mode=') do
origin = GC.generational_mode
begin
assert_false (GC.generational_mode = false)
assert_true (GC.generational_mode = true)
assert_true (GC.generational_mode = true)
ensure
GC.generational_mode = origin
end
end
# because there is no reflection on local variables in compiled code yet (but it is possible)
assert('Kernel.local_variables', '15.3.1.2.7') do
a, b = 0, 1
a += b
vars = Kernel.local_variables.sort
assert_equal [:a, :b, :vars], vars
Proc.new {
c = 2
vars = Kernel.local_variables.sort
assert_equal [:a, :b, :c, :vars], vars
}.call
end
# because mruby tries to read it from iseq, for cfunc is hardcoded to -1
# we need to override Proc#arity and read it some other way (perhaps use hash or try to store it in struct RProc somewhere)
assert('Proc#arity', '15.2.17.4.2') do
a = Proc.new {|x, y|}.arity
b = Proc.new {|x, *y, z|}.arity
c = Proc.new {|x=0, y|}.arity
d = Proc.new {|(x, y), z=0|}.arity
assert_equal 2, a
assert_equal(-3, b)
assert_equal 1, c
assert_equal 1, d
end
assert('__FILE__') do
file = __FILE__
assert_true 'test/t/syntax.rb' == file || 'test\t\syntax.rb' == file
end
assert('__LINE__') do
assert_equal 7, __LINE__
end
# these only do not work because Mrbtest is defined in driver.c specifically for testing
assert('Integer#+', '15.2.8.3.1') do
a = 1+1
b = 1+1.0
assert_equal 2, a
assert_equal 2.0, b
assert_raise(TypeError){ 0+nil }
assert_raise(TypeError){ 1+nil }
c = Mrbtest::FIXNUM_MAX + 1
d = Mrbtest::FIXNUM_MAX.__send__(:+, 1)
e = Mrbtest::FIXNUM_MAX + 1.0
assert_equal Float, c.class
assert_equal Float, d.class
assert_float e, c
assert_float e, d
end
assert('Integer#-', '15.2.8.3.2') do
a = 2-1
b = 2-1.0
assert_equal 1, a
assert_equal 1.0, b
c = Mrbtest::FIXNUM_MIN - 1
d = Mrbtest::FIXNUM_MIN.__send__(:-, 1)
e = Mrbtest::FIXNUM_MIN - 1.0
assert_equal Float, c.class
assert_equal Float, d.class
assert_float e, c
assert_float e, d
end
assert('Integer#*', '15.2.8.3.3') do
a = 1*1
b = 1*1.0
assert_equal 1, a
assert_equal 1.0, b
assert_raise(TypeError){ 0*nil }
assert_raise(TypeError){ 1*nil }
c = Mrbtest::FIXNUM_MAX * 2
d = Mrbtest::FIXNUM_MAX.__send__(:*, 2)
e = Mrbtest::FIXNUM_MAX * 2.0
assert_equal Float, c.class
assert_equal Float, d.class
assert_float e, c
assert_float e, d
end