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
- UTF8STRING =
String(Ext) Test
("\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
- .include(*modules) ⇒ Object
- .private(*methods) ⇒ Object
- .protected(*methods) ⇒ Object
- .public(*methods) ⇒ Object
Instance Method Summary collapse
- #_pp(cmd, src, tgt = nil, options = {}) ⇒ Object
-
#ArgumentError ⇒ Object
ArgumentError ISO Test.
-
#Array ⇒ Object
Array ISO Test.
-
#assert(str = 'Assertion failed', iso = '') ⇒ Object
Verify a code block.
- #assert_equal(arg1, arg2 = nil, arg3 = nil) ⇒ Object
- #assert_false(ret, msg = nil, diff = nil) ⇒ Object
-
#assert_float(exp, act, msg = nil) ⇒ Object
Fails unless
expis equal toactin terms of a Float. - #assert_include(collection, obj, msg = nil) ⇒ Object
-
#assert_kind_of(cls, obj, msg = nil) ⇒ Object
Fails unless
objis a kind ofcls. - #assert_nil(obj, msg = nil) ⇒ Object
- #assert_not_equal(arg1, arg2 = nil, arg3 = nil) ⇒ Object
- #assert_not_include(collection, obj, msg = nil) ⇒ Object
- #assert_nothing_raised(*exp) ⇒ Object
- #assert_pack(tmpl, packed, unpacked) ⇒ Object
- #assert_raise(*exc) ⇒ Object
- #assert_true(ret, 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
BasicObject.
-
#check_float(a, b) ⇒ Object
Performs fuzzy check for equality on methods returning floats on the basis of the Math::TOLERANCE constant.
- #clamp(f) ⇒ Object
-
#Class ⇒ Object
Class ISO Test.
- #cmd(s) ⇒ Object
-
#dig(idx, *args) ⇒ Object
call-seq: hsh.dig(key,…) -> object.
-
#Enumerable ⇒ Object
Enumerable ISO Test.
-
#Exception ⇒ Object
Exception ISO Test.
-
#FalseClass ⇒ Object
FalseClass ISO Test.
- #fib(n) ⇒ Object
-
#File ⇒ Object
IO Test.
-
#Hash ⇒ Object
Hash ISO Test.
-
#IndexError ⇒ Object
IndexError ISO Test.
-
#Integer ⇒ Object
Integer ISO Test.
-
#Kernel ⇒ Object
Kernel ISO Test.
- #labeled_class(name, supklass = Object, &block) ⇒ Object
-
#labeled_module(name, &block) ⇒ Object
Module ISO Test.
-
#NameError ⇒ Object
NameError ISO Test.
-
#NilClass ⇒ Object
NilClass ISO Test.
-
#NoMethodError ⇒ Object
NoMethodError ISO Test.
-
#Numeric ⇒ Object
Numeric ISO Test.
-
#Object ⇒ Object
Object ISO Test.
- #otherBasis(basis, n) ⇒ Object
-
#packtest(a, s, t) ⇒ Object
a = Array, s = String, t = Template.
- #pptest(a, s, t) ⇒ Object
-
#Proc ⇒ Object
Proc ISO Test.
-
#Range ⇒ Object
Range ISO Test.
-
#RangeError ⇒ Object
RangeError ISO Test.
-
#report ⇒ Object
Report the test result and print all assertions which were reported broken.
-
#RuntimeError ⇒ Object
RuntimeError ISO Test.
- #shellquote(s) ⇒ Object
- #skip(cause = "") ⇒ Object
-
#StandardError ⇒ Object
StandardError ISO Test.
-
#Struct ⇒ Object
Struct ISO Test.
-
#Symbol ⇒ Object
Symbol ISO Test.
-
#t_print(*args) ⇒ Object
Implementation of print due to the reason that there might be no print.
- #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
TrueClass ISO Test.
-
#TypeError ⇒ Object
TypeError ISO Test.
- #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
#_pp(cmd, src, tgt = nil, options = {}) ⇒ Object
73 74 75 76 77 78 79 |
# File 'ext/enterprise_script_service/mruby/lib/mruby-core-ext.rb', line 73 def _pp(cmd, src, tgt=nil, ={}) return unless $pp_show width = 5 template = [:indent] ? "%#{width*[:indent]}s %s %s" : "%-#{width}s %s %s" puts template % [cmd, src, tgt ? "-> #{tgt}" : nil] end |
#ArgumentError ⇒ Object
ArgumentError ISO Test
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 # this will cause an exception due to the wrong arguments a[] rescue => e1 e2 = e1 end assert_equal(Class, ArgumentError.class) assert_equal(ArgumentError, e2.class) end |
#Array ⇒ Object
Array ISO Test
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 71 |
# 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, nil)) $ko_test += 1 t_print('F') else $ok_test += 1 t_print('.') end rescue Exception => e bt = e.backtrace if $mrbtest_verbose if e.class.to_s == 'MRubyTestSkip' $asserts.push(assertion_string('Skip: ', str, iso, e, nil)) t_print('?') else $asserts.push(assertion_string("#{e.class}: ", str, iso, e, bt)) $kill_test += 1 t_print('X') end ensure $mrbtest_assert = nil end t_print("\n") if $mrbtest_verbose end |
#assert_equal(arg1, arg2 = nil, arg3 = nil) ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 103 def assert_equal(arg1, arg2 = nil, arg3 = nil) if block_given? exp, act, msg = arg1, yield, arg2 else exp, act, msg = arg1, arg2, arg3 end msg = "Expected to be equal" unless msg diff = assertion_diff(exp, act) assert_true(exp == act, msg, diff) end |
#assert_false(ret, msg = nil, diff = nil) ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 90 def assert_false(ret, msg = nil, diff = nil) if $mrbtest_assert $mrbtest_assert_idx += 1 if ret msg = "Expected #{ret.inspect} to be false" unless msg diff = assertion_diff(false, ret) unless diff $mrbtest_assert.push([$mrbtest_assert_idx, msg, diff]) end end !ret end |
#assert_float(exp, act, msg = nil) ⇒ Object
Fails unless exp is equal to act in terms of a Float
196 197 198 199 200 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 196 def assert_float(exp, act, msg = nil) msg = "Float #{exp} expected to be equal to float #{act}" unless msg diff = assertion_diff(exp, act) assert_true check_float(exp, act), msg, diff end |
#assert_include(collection, obj, msg = nil) ⇒ Object
133 134 135 136 137 138 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 133 def assert_include(collection, obj, msg = nil) msg = "Expected #{collection.inspect} to include #{obj.inspect}" unless msg diff = " Collection: #{collection.inspect}\n" + " Object: #{obj.inspect}" assert_true(collection.include?(obj), msg, diff) end |
#assert_kind_of(cls, obj, msg = nil) ⇒ Object
Fails unless obj is a kind of cls.
188 189 190 191 192 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 188 def assert_kind_of(cls, obj, msg = nil) msg = "Expected #{obj.inspect} to be a kind of #{cls}, not #{obj.class}" unless msg diff = assertion_diff(cls, obj.class) assert_true(obj.kind_of?(cls), msg, diff) end |
#assert_nil(obj, msg = nil) ⇒ Object
127 128 129 130 131 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 127 def assert_nil(obj, msg = nil) msg = "Expected #{obj.inspect} to be nil" unless msg diff = assertion_diff(nil, obj) assert_true(obj.nil?, msg, diff) end |
#assert_not_equal(arg1, arg2 = nil, arg3 = nil) ⇒ Object
115 116 117 118 119 120 121 122 123 124 125 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 115 def assert_not_equal(arg1, arg2 = nil, arg3 = nil) if block_given? exp, act, msg = arg1, yield, arg2 else exp, act, msg = arg1, arg2, arg3 end msg = "Expected to be not equal" unless msg diff = assertion_diff(exp, act) assert_false(exp == act, msg, diff) end |
#assert_not_include(collection, obj, msg = nil) ⇒ Object
140 141 142 143 144 145 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 140 def assert_not_include(collection, obj, msg = nil) msg = "Expected #{collection.inspect} to not include #{obj.inspect}" unless msg diff = " Collection: #{collection.inspect}\n" + " Object: #{obj.inspect}" assert_false(collection.include?(obj), msg, diff) end |
#assert_nothing_raised(*exp) ⇒ Object
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 170 def assert_nothing_raised(msg = nil) return true unless $mrbtest_assert $mrbtest_assert_idx += 1 begin yield true rescue Exception => e msg ||= "Expected not to raise #{exc.join(', ')} but it raised" diff = " Class: <#{e.class}>\n" + " Message: #{e.}" $mrbtest_assert.push [$mrbtest_assert_idx, msg, diff] false 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
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 147 def assert_raise(*exc) return true unless $mrbtest_assert $mrbtest_assert_idx += 1 msg = (exc.last.is_a? String) ? exc.pop : nil begin yield msg ||= "Expected to raise #{exc} but nothing was raised." diff = nil $mrbtest_assert.push [$mrbtest_assert_idx, msg, diff] false rescue *exc true rescue Exception => e msg ||= "Expected to raise #{exc}, not" diff = " Class: <#{e.class}>\n" + " Message: #{e.}" $mrbtest_assert.push [$mrbtest_assert_idx, msg, diff] false end end |
#assert_true(ret, msg = nil, diff = nil) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 78 def assert_true(ret, msg = nil, diff = nil) if $mrbtest_assert $mrbtest_assert_idx += 1 unless ret msg = "Expected #{ret.inspect} to be true" unless msg diff = assertion_diff(true, ret) unless diff $mrbtest_assert.push([$mrbtest_assert_idx, msg, diff]) end end ret end |
#assertion_diff(exp, act) ⇒ Object
73 74 75 76 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 73 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
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 20 def assertion_string(err, str, iso=nil, e=nil, bt=nil) msg = "#{err}#{str}" msg += " [#{iso}]" if iso && iso != '' msg += " => #{e.cause}" if e && e.respond_to?(:cause) msg += " => #{e.}" if e && !e.respond_to?(:cause) msg += " (mrbgems: #{GEMNAME})" if Object.const_defined?(:GEMNAME) if $mrbtest_assert && $mrbtest_assert.size > 0 $mrbtest_assert.each do |idx, assert_msg, diff| msg += "\n - Assertion[#{idx}] Failed: #{assert_msg}\n#{diff}" 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
BasicObject
4 5 6 |
# File 'ext/enterprise_script_service/mruby/test/t/basicobject.rb', line 4 assert('BasicObject') do assert_equal(Class, BasicObject.class) end |
#check_float(a, b) ⇒ Object
Performs fuzzy check for equality on methods returning floats on the basis of the Math::TOLERANCE constant.
227 228 229 230 231 232 233 234 235 236 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 227 def check_float(a, b) tolerance = Mrbtest::FLOAT_TOLERANCE a = a.to_f b = b.to_f if a.finite? and b.finite? (a-b).abs < tolerance else true end end |
#clamp(f) ⇒ Object
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 |
#Class ⇒ Object
Class ISO Test
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 |
#cmd(s) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'ext/enterprise_script_service/mruby/test/bintest.rb', line 4 def cmd(s) case RbConfig::CONFIG['host_os'] when /mswin(?!ce)|mingw|bccwin/ "bin\\#{s}.exe" else "bin/#{s}" end end |
#dig(idx, *args) ⇒ Object
call-seq:
hsh.dig(key,...) -> object
Extracts the nested value specified by the sequence of key objects by calling dig at each step, returning nil if any intermediate step is nil.
94 95 96 97 98 99 100 101 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-struct/mrblib/struct.rb', line 94 def dig(idx,*args) n = self[idx] if args.size > 0 n&.dig(*args) else n end end |
#Enumerable ⇒ Object
Enumerable ISO Test
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
Exception ISO Test
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
FalseClass ISO Test
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 |
#fib(n) ⇒ Object
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 |
#File ⇒ Object
IO Test
4 5 6 |
# File 'ext/enterprise_script_service/mruby/mrbgems/mruby-io/test/file.rb', line 4 assert('File', '15.2.21') do File.class == Class end |
#Hash ⇒ Object
Hash ISO Test
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
IndexError ISO Test
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 |
#Integer ⇒ Object
Integer ISO Test
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 |
#Kernel ⇒ Object
Kernel ISO Test
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 singleton_class.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
Module ISO Test
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 singleton_class.class_eval do define_method(:to_s) { name } alias_method :inspect, :to_s end class_eval(&block) if block end end |
#NameError ⇒ Object
NameError ISO Test
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 |
#NilClass ⇒ Object
NilClass ISO Test
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
NoMethodError ISO Test
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 |
#Numeric ⇒ Object
Numeric ISO Test
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 |
#Object ⇒ Object
Object ISO Test
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 |
#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 |
#Proc ⇒ Object
Proc ISO Test
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 |
#Range ⇒ Object
Range ISO Test
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
RangeError ISO Test
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 ⇒ Object
Report the test result and print all assertions which were reported broken.
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 205 def report() t_print("\n") $asserts.each do |msg| t_print "#{msg}\n" end $total_test = $ok_test+$ko_test+$kill_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") if Object.const_defined?(:Time) t_time = Time.now - $test_start t_print(" Time: #{t_time.round(2)} seconds\n") end end |
#RuntimeError ⇒ Object
RuntimeError ISO Test
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
13 14 15 16 17 18 19 20 |
# File 'ext/enterprise_script_service/mruby/test/bintest.rb', line 13 def shellquote(s) case RbConfig::CONFIG['host_os'] when /mswin(?!ce)|mingw|bccwin/ "\"#{s}\"" else "'#{s}'" end end |
#skip(cause = "") ⇒ Object
247 248 249 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 247 def skip(cause = "") raise MRubyTestSkip.new(cause) end |
#StandardError ⇒ Object
StandardError ISO Test
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 |
#Struct ⇒ Object
Struct ISO Test
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 |
#Symbol ⇒ Object
Symbol ISO Test
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
Implementation of print due to the reason that there might be no print
8 9 10 11 12 13 14 15 16 |
# File 'ext/enterprise_script_service/mruby/test/assert.rb', line 8 def t_print(*args) i = 0 len = args.size while i < len str = args[i].to_s __t_printstr__ str rescue print str i += 1 end 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() # create a list of integers (Li1) from 1 to SIZE li1 = (1..SIZE).to_a # copy the list to li2 (not by individual items) li2 = li1.dup # remove each individual item from left side of li2 and # append to right side of li3 (preserving order) li3 = Array.new while (not li2.empty?) li3.push(li2.shift) end # li2 must now be empty # remove each individual item from right side of li3 and # append to right side of li2 (reversing list) until li3.empty? li2.push(li3.pop) end # li3 must now be empty # reverse li1 in place li1.reverse! # check that first item is now SIZE if li1[0] != SIZE p "not SIZE" 0 else # compare li1 and li2 for equality if li1 != li2 return(0) else # return the length of the list 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
TrueClass ISO Test
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
TypeError ISO Test
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 |