Top Level Namespace
Defined Under Namespace
Modules: CRubyExtension, Comparable, Enumerable, Flags, Integral, Kernel, MRuby, Rand, ScriptCore
Classes: Addrinfo, ArgumentError, Array, Base, BasicSocket, BinTest_MrubyBinDebugger, Decimal, Derived, EOFError, Enumerator, FalseClass, File, Fixnum, Float, FloatDomainError, FrozenError, Hash, IO, IOError, IPSocket, IndexError, InlineStructTest, Integer, Interpreter, Isect, KeyError, LocalJumpError, MRubyTestSkip, Method, Module, NameError, NilClass, NoMethodError, NotImplementedError, Numeric, Object, Plane, Proc, Range, RangeError, Ray, RegexpError, RubyExtension, Scene, Socket, SocketError, Sphere, StopIteration, String, Struct, SubArray, Symbol, TCPServer, TCPSocket, Time, TrueClass, TypeError, UDPSocket, UNIXServer, UNIXSocket, UnboundMethod, Vec
Constant Summary
collapse
- GEMNAME =
""
- UTF8STRING =
("\343\201\202".size == 1)
- NUM =
300
- SIZE =
10000
- IMAGE_WIDTH =
AO render benchmark Original program © Syoyo Fujita in Javascript (and other languages)
https://code.google.com/p/aobench/
Ruby(yarv2llvm) version by Hideki Miura mruby version by Hideki Miura
64
- IMAGE_HEIGHT =
64
- NSUBSAMPLES =
2
- NAO_SAMPLES =
8
- STDIN =
IO.open(0, "r")
- STDOUT =
IO.open(1, "w")
- STDERR =
IO.open(2, "w")
- FIRST =
-> l { LEFT[RIGHT[l]] }
- IF =
-> b { b }
- LEFT =
-> p { p[-> x { -> y { x } } ] }
- RIGHT =
-> p { p[-> x { -> y { y } } ] }
- IS_EMPTY =
LEFT
- REST =
-> l { RIGHT[RIGHT[l]] }
- PACK_IS_LITTLE_ENDIAN =
"\x01\00".unpack('S')[0] == 0x01
- INVCMD =
"invalid command"
Class Method Summary
collapse
Instance Method Summary
collapse
-
#_assert_include(affirmed, collection, obj, msg = nil) ⇒ Object
-
#_assert_same(affirmed, exp, act, msg = nil) ⇒ Object
-
#_eval_assertion(meth, exp, act_or_msg, msg, block) ⇒ Object
-
#_pp(cmd, src, tgt = nil, options = {}) ⇒ Object
-
#ArgumentError ⇒ Object
-
#Array ⇒ Object
-
#assert(str = 'Assertion failed', iso = '') ⇒ Object
-
#assert_equal(exp, act_or_msg = nil, msg = nil, &block) ⇒ Object
-
#assert_false(obj, msg = nil, diff = nil) ⇒ Object
-
#assert_float(exp, act, msg = nil) ⇒ Object
Fails unless exp is equal to act in terms of a Float.
-
#assert_include(*args) ⇒ Object
-
#assert_kind_of(cls, obj, msg = nil) ⇒ Object
Fails unless obj is a kind of cls.
-
#assert_nil(obj, msg = nil) ⇒ Object
-
#assert_not_equal(exp, act_or_msg = nil, msg = nil, &block) ⇒ Object
-
#assert_not_include(*args) ⇒ Object
-
#assert_not_same(*args) ⇒ Object
-
#assert_nothing_raised(msg = nil) ⇒ Object
-
#assert_pack(tmpl, packed, unpacked) ⇒ Object
-
#assert_raise(*exc) ⇒ Object
-
#assert_same(*args) ⇒ Object
-
#assert_true(obj, msg = nil, diff = nil) ⇒ Object
-
#assertion_diff(exp, act) ⇒ Object
-
#assertion_string(err, str, iso = nil, e = nil, bt = nil) ⇒ Object
Create the assertion in a readable way.
-
#backtrace_available? ⇒ Boolean
-
#BasicObject ⇒ Object
-
#clamp(f) ⇒ Object
-
#Class ⇒ Object
-
#cmd(s) ⇒ Object
-
#Enumerable ⇒ Object
-
#Exception ⇒ Object
-
#FalseClass ⇒ Object
-
#fib(n) ⇒ Object
-
#flunk(msg = nil, diff = "Epic Fail!") ⇒ Object
-
#Hash ⇒ Object
-
#IndexError ⇒ Object
-
#Integer ⇒ Object
-
#Kernel ⇒ Object
-
#labeled_class(name, supklass = Object, &block) ⇒ Object
-
#labeled_module(name, &block) ⇒ Object
-
#NameError ⇒ Object
-
#NilClass ⇒ Object
-
#NoMethodError ⇒ Object
-
#Numeric ⇒ Object
-
#Object ⇒ Object
-
#otherBasis(basis, n) ⇒ Object
-
#packtest(a, s, t) ⇒ Object
a = Array, s = String, t = Template.
-
#pass ⇒ Object
-
#pptest(a, s, t) ⇒ Object
-
#Proc ⇒ Object
-
#Range ⇒ Object
-
#RangeError ⇒ Object
-
#report ⇒ Object
Report the test result and print all assertions which were reported broken.
-
#RuntimeError ⇒ Object
-
#shellquote(s) ⇒ Object
-
#skip(cause = "") ⇒ Object
-
#StandardError ⇒ Object
-
#Struct ⇒ Object
-
#Symbol ⇒ Object
-
#t_print(*args) ⇒ Object
-
#test_lists ⇒ Object
-
#to_array(proc) ⇒ Object
-
#to_boolean(proc) ⇒ Object
-
#to_char(c) ⇒ Object
-
#to_integer(proc) ⇒ Object
-
#to_string(s) ⇒ Object
-
#TrueClass ⇒ Object
-
#TypeError ⇒ Object
-
#unixserver_test_block ⇒ Object
-
#unpacktest(a, s, t) ⇒ Object
-
#with_unix_client ⇒ Object
-
#with_unix_server ⇒ Object
Class Method Details
.include(*modules) ⇒ Object
2
3
4
|
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb', line 2
def self.include (*modules)
self.class.include(*modules)
end
|
.private(*methods) ⇒ Object
6
7
|
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb', line 6
def self.private(*methods)
end
|
.protected(*methods) ⇒ Object
8
9
|
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb', line 8
def self.protected(*methods)
end
|
.public(*methods) ⇒ Object
10
11
|
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-toplevel-ext/mrblib/toplevel.rb', line 10
def self.public(*methods)
end
|
Instance Method Details
#_assert_include(affirmed, collection, obj, msg = nil) ⇒ Object
132
133
134
135
136
137
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 132
def _assert_include(affirmed, collection, obj, msg = nil)
unless ret = collection.include?(obj) == affirmed
diff = " Expected #{collection.inspect} to #{'not ' unless affirmed}include #{obj.inspect}."
end
assert_true(ret, msg, diff)
end
|
#_assert_same(affirmed, exp, act, msg = nil) ⇒ Object
113
114
115
116
117
118
119
120
121
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 113
def _assert_same(affirmed, exp, act, msg = nil)
unless ret = exp.equal?(act) == affirmed
exp_str, act_str = [exp, act].map do |o|
"#{o.inspect} (class=#{o.class}, oid=#{o.__id__})"
end
diff = " Expected #{act_str} to #{'not ' unless affirmed}be the same as #{exp_str}."
end
assert_true(ret, msg, diff)
end
|
#_eval_assertion(meth, exp, act_or_msg, msg, block) ⇒ Object
227
228
229
230
231
232
233
234
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 227
def _eval_assertion(meth, exp, act_or_msg, msg, block)
if block
exp, act, msg = exp, block.call, act_or_msg
else
exp, act, msg = exp, act_or_msg, msg
end
return exp.__send__(meth, act), exp, act, msg
end
|
#_pp(cmd, src, tgt = nil, options = {}) ⇒ Object
79
80
81
82
83
84
85
|
# File 'ext/enterprise_script_service/mruby/lib/mruby-core-ext.rb', line 79
def _pp(cmd, src, tgt=nil, options={})
return unless $pp_show
width = 5
template = options[:indent] ? "%#{width*options[:indent]}s %s %s" : "%-#{width}s %s %s"
puts template % [cmd, src, tgt ? "-> #{tgt}" : nil]
end
|
#ArgumentError ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'ext/enterprise_script_service/mruby/test/t/argumenterror.rb', line 4
assert('ArgumentError', '15.2.24') do
e2 = nil
a = []
begin
a[]
rescue => e1
e2 = e1
end
assert_equal(Class, ArgumentError.class)
assert_equal(ArgumentError, e2.class)
end
|
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/array.rb', line 4
assert('Array', '15.2.12') do
assert_equal(Class, Array.class)
end
|
#assert(str = 'Assertion failed', iso = '') ⇒ Object
Verify a code block.
str : A remark which will be printed in case
this assertion fails
iso : The ISO reference code of the feature
which will be tested by this
assertion
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
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 43
def assert(str = 'Assertion failed', iso = '')
t_print(str, (iso != '' ? " [#{iso}]" : ''), ' : ') if $mrbtest_verbose
begin
$mrbtest_assert = []
$mrbtest_assert_idx = 0
yield
if($mrbtest_assert.size > 0)
$asserts.push(assertion_string('Fail: ', str, iso))
$ko_test += 1
t_print('F')
else
$ok_test += 1
t_print('.')
end
rescue MRubyTestSkip => e
$asserts.push(assertion_string('Skip: ', str, iso, e))
$skip_test += 1
t_print('?')
rescue Exception => e
bt = e.backtrace if $mrbtest_verbose
$asserts.push(assertion_string("#{e.class}: ", str, iso, e, bt))
$kill_test += 1
t_print('X')
ensure
$mrbtest_assert = nil
end
t_print("\n") if $mrbtest_verbose
end
|
#assert_equal(exp, act_or_msg = nil, msg = nil, &block) ⇒ Object
95
96
97
98
99
100
101
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 95
def assert_equal(exp, act_or_msg = nil, msg = nil, &block)
ret, exp, act, msg = _eval_assertion(:==, exp, act_or_msg, msg, block)
unless ret
diff = assertion_diff(exp, act)
end
assert_true(ret, msg, diff)
end
|
#assert_false(obj, msg = nil, diff = nil) ⇒ Object
88
89
90
91
92
93
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 88
def assert_false(obj, msg = nil, diff = nil)
unless obj == false
diff ||= " Expected #{obj.inspect} to be false."
end
assert_true(!obj, msg, diff)
end
|
#assert_float(exp, act, msg = nil) ⇒ Object
Fails unless exp is equal to act in terms of a Float
150
151
152
153
154
155
156
157
158
159
160
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 150
def assert_float(exp, act, msg = nil)
e, a = exp.to_f, act.to_f
if (e.infinite? || a.infinite?) && e != a ||
e.nan? && !a.nan? || !e.nan? && a.nan?
flunk(msg, " Expected #{act} to be #{exp}.")
elsif (n = (e - a).abs) > Mrbtest::FLOAT_TOLERANCE
flunk(msg, " Expected |#{exp} - #{act}| (#{n}) to be <= #{Mrbtest::FLOAT_TOLERANCE}.")
else
pass
end
end
|
#assert_include(*args) ⇒ Object
130
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 130
def assert_include(*args); _assert_include(true, *args) end
|
#assert_kind_of(cls, obj, msg = nil) ⇒ Object
Fails unless obj is a kind of cls.
141
142
143
144
145
146
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 141
def assert_kind_of(cls, obj, msg = nil)
unless ret = obj.kind_of?(cls)
diff = " Expected #{obj.inspect} to be a kind of #{cls}, not #{obj.class}."
end
assert_true(ret, msg, diff)
end
|
#assert_nil(obj, msg = nil) ⇒ Object
123
124
125
126
127
128
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 123
def assert_nil(obj, msg = nil)
unless ret = obj.nil?
diff = " Expected #{obj.inspect} to be nil."
end
assert_true(ret, msg, diff)
end
|
#assert_not_equal(exp, act_or_msg = nil, msg = nil, &block) ⇒ Object
103
104
105
106
107
108
109
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 103
def assert_not_equal(exp, act_or_msg = nil, msg = nil, &block)
ret, exp, act, msg = _eval_assertion(:==, exp, act_or_msg, msg, block)
if ret
diff = " Expected #{act.inspect} to not be equal to #{exp.inspect}."
end
assert_true(!ret, msg, diff)
end
|
#assert_not_include(*args) ⇒ Object
131
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 131
def assert_not_include(*args); _assert_include(false, *args) end
|
#assert_not_same(*args) ⇒ Object
112
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 112
def assert_not_same(*args); _assert_same(false, *args) end
|
#assert_nothing_raised(msg = nil) ⇒ Object
180
181
182
183
184
185
186
187
188
189
190
191
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 180
def assert_nothing_raised(msg = nil)
begin
yield
rescue Exception => e
diff = " Exception raised:\n" \
" Class: <#{e.class}>\n" \
" Message: <#{e}>"
flunk(msg, diff)
else
pass
end
end
|
#assert_pack(tmpl, packed, unpacked) ⇒ Object
92
93
94
95
|
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-pack/test/pack.rb', line 92
def assert_pack tmpl, packed, unpacked
assert_equal packed, unpacked.pack(tmpl)
assert_equal unpacked, packed.unpack(tmpl)
end
|
#assert_raise(*exc) ⇒ Object
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 162
def assert_raise(*exc)
msg = (exc.last.is_a? String) ? exc.pop : nil
exc = exc.empty? ? StandardError : exc.size == 1 ? exc[0] : exc
begin
yield
rescue *exc
pass
rescue Exception => e
diff = " #{exc} exception expected, not\n" \
" Class: <#{e.class}>\n" \
" Message: <#{e}>"
flunk(msg, diff)
else
diff = " #{exc} expected but nothing was raised."
flunk(msg, diff)
end
end
|
#assert_same(*args) ⇒ Object
111
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 111
def assert_same(*args); _assert_same(true, *args) end
|
#assert_true(obj, msg = nil, diff = nil) ⇒ Object
77
78
79
80
81
82
83
84
85
86
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 77
def assert_true(obj, msg = nil, diff = nil)
if $mrbtest_assert
$mrbtest_assert_idx += 1
unless obj == true
diff ||= " Expected #{obj.inspect} to be true."
$mrbtest_assert.push([$mrbtest_assert_idx, msg, diff])
end
end
obj
end
|
#assertion_diff(exp, act) ⇒ Object
72
73
74
75
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 72
def assertion_diff(exp, act)
" Expected: #{exp.inspect}\n" \
" Actual: #{act.inspect}"
end
|
#assertion_string(err, str, iso = nil, e = nil, bt = nil) ⇒ Object
Create the assertion in a readable way
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 19
def assertion_string(err, str, iso=nil, e=nil, bt=nil)
msg = "#{err}#{str}"
msg += " [#{iso}]" if iso && !iso.empty?
msg += " => #{e}" if e && !e.to_s.empty?
msg += " (#{GEMNAME == 'mruby-test' ? 'core' : "mrbgems: #{GEMNAME}"})"
if $mrbtest_assert && $mrbtest_assert.size > 0
$mrbtest_assert.each do |idx, assert_msg, diff|
msg += "\n - Assertion[#{idx}]"
msg += " #{assert_msg}." if assert_msg && !assert_msg.empty?
msg += "\n#{diff}" if diff && !diff.empty?
end
end
msg += "\nbacktrace:\n\t#{bt.join("\n\t")}" if bt
msg
end
|
#backtrace_available? ⇒ Boolean
379
380
381
382
383
384
385
|
# File 'ext/enterprise_script_service/mruby/test/t/exception.rb', line 379
def backtrace_available?
begin
raise "XXX"
rescue => exception
not exception.backtrace.empty?
end
end
|
#BasicObject ⇒ Object
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/basicobject.rb', line 4
assert('BasicObject') do
assert_equal(Class, BasicObject.class)
end
|
171
172
173
174
175
176
177
178
179
180
|
# File 'ext/enterprise_script_service/mruby/benchmark/bm_ao_render.rb', line 171
def clamp(f)
i = f * 255.5
if i > 255.0
i = 255.0
end
if i < 0.0
i = 0.0
end
i.to_i
end
|
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/class.rb', line 4
assert('Class', '15.2.3') do
assert_equal(Class, Class.class)
end
|
6
7
8
9
10
11
12
13
|
# File 'ext/enterprise_script_service/mruby/test/bintest.rb', line 6
def cmd(s)
case RbConfig::CONFIG['host_os']
when /mswin(?!ce)|mingw|bccwin/
"bin\\#{s}.exe"
else
"bin/#{s}"
end
end
|
#Enumerable ⇒ Object
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/enumerable.rb', line 4
assert('Enumerable', '15.3.2') do
assert_equal(Module, Enumerable.class)
end
|
#Exception ⇒ Object
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/exception.rb', line 4
assert('Exception', '15.2.22') do
assert_equal Class, Exception.class
end
|
#FalseClass ⇒ Object
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/false.rb', line 4
assert('FalseClass', '15.2.6') do
assert_equal Class, FalseClass.class
end
|
2
3
4
5
|
# File 'ext/enterprise_script_service/mruby/benchmark/bm_fib.rb', line 2
def fib n
return n if n < 2
fib(n-2) + fib(n-1)
end
|
#flunk(msg = nil, diff = "Epic Fail!") ⇒ Object
197
198
199
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 197
def flunk(msg = nil, diff = "Epic Fail!")
assert_true(false, msg, diff)
end
|
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/hash.rb', line 4
assert('Hash', '15.2.13') do
assert_equal Class, Hash.class
end
|
#IndexError ⇒ Object
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/indexerror.rb', line 4
assert('IndexError', '15.2.33') do
assert_equal Class, IndexError.class
end
|
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/integer.rb', line 4
assert('Integer', '15.2.8') do
assert_equal Class, Integer.class
end
|
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/kernel.rb', line 4
assert('Kernel', '15.3.1') do
assert_equal Module, Kernel.class
end
|
#labeled_class(name, supklass = Object, &block) ⇒ Object
14
15
16
17
18
19
20
21
22
|
# File 'ext/enterprise_script_service/mruby/test/t/module.rb', line 14
def labeled_class(name, supklass = Object, &block)
Class.new(supklass) do
(class <<self; self end).class_eval do
define_method(:to_s) { name }
alias_method :inspect, :to_s
end
class_eval(&block) if block
end
end
|
#labeled_module(name, &block) ⇒ Object
4
5
6
7
8
9
10
11
12
|
# File 'ext/enterprise_script_service/mruby/test/t/module.rb', line 4
def labeled_module(name, &block)
Module.new do
(class <<self; self end).class_eval do
define_method(:to_s) { name }
alias_method :inspect, :to_s
end
class_eval(&block) if block
end
end
|
#NameError ⇒ Object
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/nameerror.rb', line 4
assert('NameError', '15.2.31') do
assert_equal Class, NameError.class
end
|
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/nil.rb', line 4
assert('NilClass', '15.2.4') do
assert_equal Class, NilClass.class
end
|
#NoMethodError ⇒ Object
4
5
6
7
8
9
|
# File 'ext/enterprise_script_service/mruby/test/t/nomethoderror.rb', line 4
assert('NoMethodError', '15.2.32') do
NoMethodError.class == Class
assert_raise NoMethodError do
doesNotExistAsAMethodNameForVerySure("")
end
end
|
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/numeric.rb', line 4
assert('Numeric', '15.2.7') do
assert_equal(Class, Numeric.class)
end
|
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/object.rb', line 4
assert('Object', '15.2.1') do
assert_equal Class, Object.class
end
|
#otherBasis(basis, n) ⇒ Object
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
|
# File 'ext/enterprise_script_service/mruby/benchmark/bm_ao_render.rb', line 182
def otherBasis(basis, n)
basis[2] = Vec.new(n.x, n.y, n.z)
basis[1] = Vec.new(0.0, 0.0, 0.0)
if n.x < 0.6 and n.x > -0.6
basis[1].x = 1.0
elsif n.y < 0.6 and n.y > -0.6
basis[1].y = 1.0
elsif n.z < 0.6 and n.z > -0.6
basis[1].z = 1.0
else
basis[1].x = 1.0
end
basis[0] = basis[1].vcross(basis[2])
basis[0] = basis[0].vnormalize
basis[1] = basis[2].vcross(basis[0])
basis[1] = basis[1].vnormalize
end
|
#packtest(a, s, t) ⇒ Object
a = Array, s = String, t = Template
5
6
7
8
9
10
11
12
13
14
15
|
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-pack/packtest.rb', line 5
def packtest(a, s, t)
begin
r = a.pack(t)
return if r == s
puts "#{a.inspect}.pack(#{t.inspect}) -> #{r.inspect} should be #{s.inspect}"
rescue => r
unless r.is_a? s
puts "#{a.inspect}.pack(#{t.inspect}) -> #{r.inspect} should be #{s.inspect}"
end
end
end
|
193
194
195
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 193
def pass
assert_true(true)
end
|
#pptest(a, s, t) ⇒ Object
23
24
25
26
|
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-pack/packtest.rb', line 23
def pptest(a, s, t)
packtest(a, s, t)
unpacktest(a, s, t)
end
|
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/proc.rb', line 4
assert('Proc', '15.2.17') do
assert_equal Class, Proc.class
end
|
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/range.rb', line 4
assert('Range', '15.2.14') do
assert_equal Class, Range.class
end
|
#RangeError ⇒ Object
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/rangeerror.rb', line 4
assert('RangeError', '15.2.26') do
assert_equal Class, RangeError.class
end
|
Report the test result and print all assertions which were reported broken.
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 204
def report
t_print("\n")
$asserts.each do |msg|
t_print("#{msg}\n")
end
$total_test = $ok_test + $ko_test + $kill_test + $skip_test
t_print("Total: #{$total_test}\n")
t_print(" OK: #{$ok_test}\n")
t_print(" KO: #{$ko_test}\n")
t_print("Crash: #{$kill_test}\n")
t_print(" Skip: #{$skip_test}\n")
if Object.const_defined?(:Time)
t_time = Time.now - $test_start
t_print(" Time: #{t_time.round(2)} seconds\n")
end
$ko_test == 0 && $kill_test == 0
end
|
#RuntimeError ⇒ Object
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/runtimeerror.rb', line 4
assert('RuntimeError', '15.2.28') do
assert_equal Class, RuntimeError.class
end
|
#shellquote(s) ⇒ Object
15
16
17
18
19
20
21
22
|
# File 'ext/enterprise_script_service/mruby/test/bintest.rb', line 15
def shellquote(s)
case RbConfig::CONFIG['host_os']
when /mswin(?!ce)|mingw|bccwin/
"\"#{s}\""
else
"'#{s}'"
end
end
|
#skip(cause = "") ⇒ Object
240
241
242
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 240
def skip(cause = "")
raise MRubyTestSkip.new(cause)
end
|
#StandardError ⇒ Object
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/standarderror.rb', line 4
assert('StandardError', '15.2.23') do
assert_equal Class, StandardError.class
end
|
4
5
6
|
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-struct/test/struct.rb', line 4
assert('Struct', '15.2.18') do
assert_equal Class, Struct.class
end
|
4
5
6
7
8
9
|
# File 'ext/enterprise_script_service/mruby/test/t/symbol.rb', line 4
assert('Symbol') do
assert_equal :"a", :a
assert_equal :"a#{1}", :a1
assert_equal :'a', :a
assert_equal :'a#{1}', :"a\#{1}"
end
|
#t_print(*args) ⇒ Object
10
11
12
13
14
|
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 10
def t_print(*args)
print(*args)
$stdout.flush
nil
end
|
#test_lists ⇒ Object
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
|
# File 'ext/enterprise_script_service/mruby/benchmark/bm_so_lists.rb', line 6
def test_lists()
li1 = (1..SIZE).to_a
li2 = li1.dup
li3 = Array.new
while (not li2.empty?)
li3.push(li2.shift)
end
until li3.empty?
li2.push(li3.pop)
end
li1.reverse!
if li1[0] != SIZE
p "not SIZE"
0
else
if li1 != li2
return(0)
else
li1.length
end
end
end
|
#to_array(proc) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'ext/enterprise_script_service/mruby/benchmark/bm_app_lc_fizzbuzz.rb', line 28
def to_array(proc)
array = []
until to_boolean(IS_EMPTY[proc])
array.push(FIRST[proc])
proc = REST[proc]
end
array
end
|
#to_boolean(proc) ⇒ Object
24
25
26
|
# File 'ext/enterprise_script_service/mruby/benchmark/bm_app_lc_fizzbuzz.rb', line 24
def to_boolean(proc)
IF[proc][true][false]
end
|
#to_char(c) ⇒ Object
39
40
41
|
# File 'ext/enterprise_script_service/mruby/benchmark/bm_app_lc_fizzbuzz.rb', line 39
def to_char(c)
'0123456789BFiuz'.slice(to_integer(c))
end
|
#to_integer(proc) ⇒ Object
20
21
22
|
# File 'ext/enterprise_script_service/mruby/benchmark/bm_app_lc_fizzbuzz.rb', line 20
def to_integer(proc)
proc[-> n { n + 1 }][0]
end
|
#to_string(s) ⇒ Object
43
44
45
|
# File 'ext/enterprise_script_service/mruby/benchmark/bm_app_lc_fizzbuzz.rb', line 43
def to_string(s)
to_array(s).map { |c| to_char(c) }.join
end
|
#TrueClass ⇒ Object
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/true.rb', line 4
assert('TrueClass', '15.2.5') do
assert_equal Class, TrueClass.class
end
|
#TypeError ⇒ Object
4
5
6
|
# File 'ext/enterprise_script_service/mruby/test/t/typeerror.rb', line 4
assert('TypeError', '15.2.29') do
assert_equal Class, TypeError.class
end
|
#unixserver_test_block ⇒ Object
3
4
5
6
7
8
9
10
11
12
|
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-socket/test/unix.rb', line 3
def unixserver_test_block
path = SocketTest.tmppath
File.unlink path rescue nil
begin
result = yield path
ensure
File.unlink path rescue nil
end
result
end
|
#unpacktest(a, s, t) ⇒ Object
17
18
19
20
21
|
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-pack/packtest.rb', line 17
def unpacktest(a, s, t)
r = s.unpack(t)
return if r == a
puts "#{s.inspect}.unpack(#{t.inspect}) -> #{r.inspect} should be #{a.inspect}"
end
|
#with_unix_client ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-socket/test/unix.rb', line 22
def with_unix_client
with_unix_server do |path, server|
UNIXSocket.open(path) do |csock|
ssock = server.accept
begin
yield path, server, ssock, csock
ensure
ssock.close unless ssock.closed? rescue nil
end
end
end
end
|
#with_unix_server ⇒ Object
14
15
16
17
18
19
20
|
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-socket/test/unix.rb', line 14
def with_unix_server
unixserver_test_block do |path|
UNIXServer.open(path) { |server|
yield path, server
}
end
end
|