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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
##
# String ISO Test
assert('String', '15.2.10') do
String.class == Class
end
assert('String#*', '15.2.10.5.1') do
'a' * 5 == 'aaaaa'
end
assert('String#+', '15.2.10.5.2') do
'a' + 'b' == 'ab'
end
assert('String#<=>', '15.2.10.5.3') do
a = '' <=> ''
b = '' <=> 'not empty'
c = 'not empty' <=> ''
d = 'abc' <=> 'cba'
e = 'cba' <=> 'abc'
a == 0 and b == -1 and c == 1 and
d == -1 and e == 1
end
assert('String#==', '15.2.10.5.4') do
'abc' == 'abc' and not 'abc' == 'cba'
end
# TODO: SEGFAULT ATM assert('String#=~', '15.2.10.5.5')
assert('String#[]', '15.2.10.5.6') do
# length of args is 1
a = 'abc'[0]
b = 'abc'[-1]
c = 'abc'[10]
d = 'abc'[-10]
# length of args is 2
a1 = 'abc'[0, -1]
b1 = 'abc'[10, 0]
c1 = 'abc'[-10, 0]
d1 = 'abc'[0, 0]
e1 = 'abc'[1, 2]
# args is RegExp
# TODO SEGFAULT ATM
# args is String
a3 = 'abc'['bc']
b3 = 'abc'['XX']
a == 'a' and b == 'c' and c == nil and d == nil and
a1 == nil and b1 == nil and c1 == nil and d1 == '' and
e1 == 'bc' and
a3 == 'bc' and b3 == nil
end
assert('String#capitalize', '15.2.10.5.7') do
a = 'abc'
a.capitalize
a == 'abc' and 'abc'.capitalize == 'Abc'
end
assert('String#capitalize!', '15.2.10.5.8') do
a = 'abc'
a.capitalize!
a == 'Abc'
end
assert('String#chomp', '15.2.10.5.9') do
a = 'abc'.chomp
b = ''.chomp
c = "abc\n".chomp
d = "abc\n\n".chomp
e = "abc\t".chomp("\t")
f = "abc\n"
f.chomp
a == 'abc' and b == '' and c == 'abc' and
d == "abc\n" and e == 'abc' and f == "abc\n"
end
assert('String#chomp!', '15.2.10.5.10') do
a = 'abc'
b = ''
c = "abc\n"
d = "abc\n\n"
e = "abc\t"
a.chomp!
b.chomp!
c.chomp!
d.chomp!
e.chomp!("\t")
a == 'abc' and b == '' and c == 'abc' and
d == "abc\n" and e == 'abc'
end
assert('String#chop', '15.2.10.5.11') do
a = ''.chop
b = 'abc'.chop
c = 'abc'
c.chop
a == '' and b == 'ab' and c == 'abc'
end
assert('String#chop!', '15.2.10.5.12') do
a = ''
b = 'abc'
a.chop!
b.chop!
a == '' and b == 'ab'
end
assert('String#downcase', '15.2.10.5.13') do
a = 'ABC'.downcase
b = 'ABC'
b.downcase
a == 'abc' and b == 'ABC'
end
assert('String#downcase!', '15.2.10.5.14') do
a = 'ABC'
a.downcase!
a == 'abc'
end
assert('String#each_line', '15.2.10.5.15') do
a = "first line\nsecond line\nthird line"
list = ["first line\n", "second line\n", "third line"]
n_list = []
a.each_line do |line|
n_list << line
end
list == n_list
end
assert('String#empty?', '15.2.10.5.16') do
a = ''
b = 'not empty'
a.empty? and not b.empty?
end
assert('String#eql?', '15.2.10.5.17') do
'abc'.eql?('abc') and not 'abc'.eql?('cba')
end
# TODO ATM broken assert('String#gsub', '15.2.10.5.18') do
# TODO ATM broken assert('String#gsub!', '15.2.10.5.19') do
assert('String#hash', '15.2.10.5.20') do
a = 'abc'
a.hash == 'abc'.hash
end
assert('String#include?', '15.2.10.5.21') do
'abc'.include?(97) and not 'abc'.include?(100) and
'abc'.include?('a') and not 'abc'.include?('d')
end
assert('String#index', '15.2.10.5.22') do
'abc'.index('a') == 0 and 'abc'.index('d') == nil and
'abcabc'.index('a', 1) == 3
end
assert('String#initialize', '15.2.10.5.23') do
a = ''
a.initialize('abc')
a == 'abc'
end
assert('String#initialize_copy', '15.2.10.5.24') do
a = ''
a.initialize_copy('abc')
a == 'abc'
end
assert('String#intern', '15.2.10.5.25') do
'abc'.intern == :abc
end
assert('String#length', '15.2.10.5.26') do
'abc'.length == 3
end
# TODO Broken ATM assert('String#match', '15.2.10.5.27') do
assert('String#replace', '15.2.10.5.28') do
a = ''
a.replace('abc')
a == 'abc'
end
assert('String#reverse', '15.2.10.5.29') do
a = 'abc'
a.reverse
a == 'abc' and 'abc'.reverse == 'cba'
end
assert('String#reverse!', '15.2.10.5.30') do
a = 'abc'
a.reverse!
a == 'cba' and 'abc'.reverse! == 'cba'
end
assert('String#rindex', '15.2.10.5.31') do
'abc'.rindex('a') == 0 and 'abc'.rindex('d') == nil and
'abcabc'.rindex('a', 1) == 0 and 'abcabc'.rindex('a', 4) == 3
end
# TODO Broken ATM assert('String#scan', '15.2.10.5.32') do
assert('String#size', '15.2.10.5.33') do
'abc'.size == 3
end
assert('String#slice', '15.2.10.5.34') do
# length of args is 1
a = 'abc'.slice(0)
b = 'abc'.slice(-1)
c = 'abc'.slice(10)
d = 'abc'.slice(-10)
# length of args is 2
a1 = 'abc'.slice(0, -1)
b1 = 'abc'.slice(10, 0)
c1 = 'abc'.slice(-10, 0)
d1 = 'abc'.slice(0, 0)
e1 = 'abc'.slice(1, 2)
# args is RegExp
# TODO SEGFAULT ATM
# args is String
a3 = 'abc'.slice('bc')
b3 = 'abc'.slice('XX')
a == 'a' and b == 'c' and c == nil and d == nil and
a1 == nil and b1 == nil and c1 == nil and d1 == '' and
e1 == 'bc' and
a3 == 'bc' and b3 == nil
end
# TODO Broken ATM
assert('String#split', '15.2.10.5.35') do
# without RegExp behavior is actually unspecified
a = 'abc abc abc'.split
a == ['abc', 'abc', 'abc']
end
# TODO ATM broken assert('String#sub', '15.2.10.5.36') do
# TODO ATM broken assert('String#sub!', '15.2.10.5.37') do
assert('String#to_i', '15.2.10.5.38') do
a = ''.to_i
b = '123456789'.to_i
c = 'a'.to_i(16)
d = '100'.to_i(2)
a == 0 and b == 123456789 and c == 10 and d == 4
end
assert('String#to_f', '15.2.10.5.39') do
a = ''.to_f
b = '123456789'.to_f
c = '12345.6789'.to_f
check_float(a, 0.0) and check_float(b, 123456789.0) and
check_float(c, 12345.6789)
end
assert('String#to_s', '15.2.10.5.40') do
'abc'.to_s == 'abc'
end
assert('String#to_sym', '15.2.10.5.41') do
'abc'.to_sym == :abc
end
assert('String#upcase', '15.2.10.5.42') do
a = 'abc'.upcase
b = 'abc'
b.upcase
a == 'ABC' and b == 'abc'
end
assert('String#upcase!', '15.2.10.5.43') do
a = 'abc'
a.upcase!
a == 'ABC'
end
|