mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge branch 'master' of github.com:mruby/mruby
This commit is contained in:
@@ -13,18 +13,27 @@ MRuby::CrossBuild.new("Arduino Due") do |conf|
|
||||
|
||||
conf.cc do |cc|
|
||||
cc.command = "#{BIN_PATH}/arm-none-eabi-gcc"
|
||||
cc.include_paths = ["#{SAM_PATH}/system/libsam -I#{SAM_PATH}/system/CMSIS/CMSIS/Include/",
|
||||
cc.include_paths << ["#{SAM_PATH}/system/libsam -I#{SAM_PATH}/system/CMSIS/CMSIS/Include/",
|
||||
"#{SAM_PATH}/system/CMSIS/Device/ATMEL/",
|
||||
"#{SAM_PATH}/cores/arduino -I#{TARGET_PATH}",
|
||||
"#{MRUBY_ROOT}/include"]
|
||||
cc.flags << '-g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 ' +
|
||||
'-Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=152 -D__SAM3X8E__ -mthumb -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON'
|
||||
"#{SAM_PATH}/cores/arduino -I#{TARGET_PATH}"]
|
||||
cc.flags = %w(-g -Os -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500
|
||||
-Dprintf=iprintf -mcpu=cortex-m3 -DF_CPU=84000000L -DARDUINO=152 -D__SAM3X8E__ -mthumb -DUSB_PID=0x003e -DUSB_VID=0x2341 -DUSBCON)
|
||||
cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
|
||||
end
|
||||
|
||||
conf.cxx do |cxx|
|
||||
cxx.command = conf.cc.command.dup
|
||||
cxx.include_paths = conf.cc.include_paths.dup
|
||||
cxx.flags = conf.cc.flags.dup
|
||||
cxx.compile_options = conf.cc.compile_options.dup
|
||||
end
|
||||
|
||||
conf.archiver do |archiver|
|
||||
archiver.command = "#{BIN_PATH}/arm-none-eabi-ar"
|
||||
archiver.archive_options = 'rcs %{outfile} %{objs}'
|
||||
end
|
||||
|
||||
#no executables
|
||||
conf.bins = []
|
||||
|
||||
end
|
||||
|
||||
@@ -9,26 +9,36 @@ MRuby::CrossBuild.new("chipKitMax32") do |conf|
|
||||
toolchain :gcc
|
||||
|
||||
# Mac OS X
|
||||
# MPIDE_PATH = '/Applications/mpide.app/Contents/Resources/Java'
|
||||
# MPIDE_PATH = '/Applications/Mpide.app/Contents/Resources/Java'
|
||||
# GNU Linux
|
||||
MPIDE_PATH = '/opt/mpide-0023-linux-20120903'
|
||||
|
||||
PIC32_PATH = "#{MPIDE_PATH}/hardware/pic32"
|
||||
|
||||
conf.cc do |cc|
|
||||
cc.command="#{PIC32_PATH}/compiler/pic32-tools/bin/pic32-gcc"
|
||||
cc.include_paths = ["#{PIC32_PATH}/cores/pic32",
|
||||
cc.command = "#{PIC32_PATH}/compiler/pic32-tools/bin/pic32-gcc"
|
||||
cc.include_paths << ["#{PIC32_PATH}/cores/pic32",
|
||||
"#{PIC32_PATH}/variants/Max32",
|
||||
"#{MRUBY_ROOT}/include"]
|
||||
cc.flags << "-O2 -mno-smart-io -w -ffunction-sections -fdata-sections -g -mdebugger -Wcast-align " +
|
||||
"-fno-short-double -mprocessor=32MX795F512L -DF_CPU=80000000L -DARDUINO=23 -D_BOARD_MEGA_ " +
|
||||
"-DMPIDEVER=0x01000202 -DMPIDE=23"
|
||||
"#{PIC32_PATH}/libraries"]
|
||||
cc.flags = %w(-O2 -mno-smart-io -w -ffunction-sections -fdata-sections -g -mdebugger -Wcast-align
|
||||
-fno-short-double -mprocessor=32MX795F512L -DF_CPU=80000000L -DARDUINO=23 -D_BOARD_MEGA_
|
||||
-DMPIDEVER=0x01000202 -DMPIDE=23)
|
||||
cc.compile_options = "%{flags} -o %{outfile} -c %{infile}"
|
||||
end
|
||||
|
||||
conf.cxx do |cxx|
|
||||
cxx.command = conf.cc.command.dup
|
||||
cxx.include_paths = conf.cc.include_paths.dup
|
||||
cxx.flags = conf.cc.flags.dup
|
||||
cxx.compile_options = conf.cc.compile_options.dup
|
||||
end
|
||||
|
||||
conf.archiver do |archiver|
|
||||
archiver.command = "#{PIC32_PATH}/compiler/pic32-tools/bin/pic32-ar"
|
||||
archiver.archive_options = 'rcs %{outfile} %{objs}'
|
||||
end
|
||||
|
||||
#no executables
|
||||
conf.bins = []
|
||||
|
||||
end
|
||||
|
||||
@@ -81,7 +81,7 @@ module MRuby
|
||||
instance_eval(&@build_config_initializer) if @build_config_initializer
|
||||
|
||||
compilers.each do |compiler|
|
||||
compiler.define_rules build_dir, "#{dir}/"
|
||||
compiler.define_rules build_dir, "#{dir}"
|
||||
end
|
||||
|
||||
define_gem_init_builder
|
||||
|
||||
+22
-2
@@ -99,13 +99,25 @@ def assert_false(ret, msg = nil, diff = nil)
|
||||
!ret
|
||||
end
|
||||
|
||||
def assert_equal(exp, act, msg = nil)
|
||||
def assert_equal(arg1, arg2 = nil, arg3 = nil)
|
||||
if block_given?
|
||||
exp, act, msg = yield, arg1, 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
|
||||
|
||||
def assert_not_equal(exp, act, msg = nil)
|
||||
def assert_not_equal(arg1, arg2 = nil, arg3 = nil)
|
||||
if block_given?
|
||||
exp, act, msg = yield, arg1, 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)
|
||||
@@ -169,6 +181,14 @@ def assert_kind_of(cls, obj, msg = nil)
|
||||
assert_true(obj.kind_of?(cls), msg, diff)
|
||||
end
|
||||
|
||||
##
|
||||
# Fails unless +exp+ is equal to +act+ in terms of a Float
|
||||
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
|
||||
|
||||
##
|
||||
# Report the test result and print all assertions
|
||||
# which were reported broken.
|
||||
|
||||
+157
-108
@@ -2,17 +2,19 @@
|
||||
# Bootstrap tests for blocks
|
||||
|
||||
assert('BS Block 1') do
|
||||
1.times{
|
||||
begin
|
||||
a = 1
|
||||
ensure
|
||||
foo = nil
|
||||
end
|
||||
} == 1
|
||||
assert_equal(1) do
|
||||
1.times{
|
||||
begin
|
||||
a = 1
|
||||
ensure
|
||||
foo = nil
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 2') do
|
||||
[1,2,3].find{|x| x == 2} == 2
|
||||
assert_equal [1,2,3].find{|x| x == 2}, 2
|
||||
end
|
||||
|
||||
assert('BS Block 3') do
|
||||
@@ -22,7 +24,7 @@ assert('BS Block 3') do
|
||||
[1, 2, 3].each(&block)
|
||||
end
|
||||
end
|
||||
E.new.find {|x| x == 2 } == 2
|
||||
assert_equal E.new.find {|x| x == 2 }, 2
|
||||
end
|
||||
|
||||
assert('BS Block 3') do
|
||||
@@ -30,7 +32,7 @@ assert('BS Block 3') do
|
||||
for x in [1, 2, 3]
|
||||
sum += x
|
||||
end
|
||||
sum == 6
|
||||
assert_equal sum, 6
|
||||
end
|
||||
|
||||
assert('BS Block 4') do
|
||||
@@ -38,7 +40,7 @@ assert('BS Block 4') do
|
||||
for x in (1..5)
|
||||
sum += x
|
||||
end
|
||||
sum == 15
|
||||
assert_equal sum, 15
|
||||
end
|
||||
|
||||
assert('BS Block 5') do
|
||||
@@ -46,37 +48,43 @@ assert('BS Block 5') do
|
||||
for x in []
|
||||
sum += x
|
||||
end
|
||||
sum == 0
|
||||
assert_equal sum, 0
|
||||
end
|
||||
|
||||
assert('BS Block 6') do
|
||||
ans = []
|
||||
1.times{
|
||||
for n in 1..3
|
||||
a = n
|
||||
ans << a
|
||||
end
|
||||
} == 1
|
||||
assert_equal(1) do
|
||||
1.times{
|
||||
for n in 1..3
|
||||
a = n
|
||||
ans << a
|
||||
end
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 7') do
|
||||
ans = []
|
||||
for m in 1..3
|
||||
for n in 2..4
|
||||
a = [m, n]
|
||||
ans << a
|
||||
assert_equal((1..3)) do
|
||||
for m in 1..3
|
||||
for n in 2..4
|
||||
a = [m, n]
|
||||
ans << a
|
||||
end
|
||||
end
|
||||
end == (1..3)
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 8') do
|
||||
(1..3).to_a == [1, 2, 3]
|
||||
assert_equal (1..3).to_a, [1, 2, 3]
|
||||
end
|
||||
|
||||
assert('BS Block 9') do
|
||||
(1..3).map{|e|
|
||||
e * 4
|
||||
} == [4, 8, 12]
|
||||
assert_equal([4, 8, 12]) do
|
||||
(1..3).map{|e|
|
||||
e * 4
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 10') do
|
||||
@@ -87,11 +95,13 @@ assert('BS Block 10') do
|
||||
yield
|
||||
end
|
||||
|
||||
m{
|
||||
n{
|
||||
100
|
||||
assert_equal(100) do
|
||||
m{
|
||||
n{
|
||||
100
|
||||
}
|
||||
}
|
||||
} == 100
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 11') do
|
||||
@@ -99,11 +109,13 @@ assert('BS Block 11') do
|
||||
yield 1
|
||||
end
|
||||
|
||||
m{|ib|
|
||||
m{|jb|
|
||||
i = 20
|
||||
assert_equal(20) do
|
||||
m{|ib|
|
||||
m{|jb|
|
||||
i = 20
|
||||
}
|
||||
}
|
||||
} == 20
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 12') do
|
||||
@@ -111,12 +123,14 @@ assert('BS Block 12') do
|
||||
yield 1
|
||||
end
|
||||
|
||||
m{|ib|
|
||||
m{|jb|
|
||||
ib = 20
|
||||
kb = 2
|
||||
assert_equal(2) do
|
||||
m{|ib|
|
||||
m{|jb|
|
||||
ib = 20
|
||||
kb = 2
|
||||
}
|
||||
}
|
||||
} == 2
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 13') do
|
||||
@@ -130,13 +144,15 @@ assert('BS Block 13') do
|
||||
yield
|
||||
end
|
||||
|
||||
iter1{
|
||||
jb = 2
|
||||
assert_equal(3) do
|
||||
iter1{
|
||||
jb = 3
|
||||
jb = 2
|
||||
iter1{
|
||||
jb = 3
|
||||
}
|
||||
jb
|
||||
}
|
||||
jb
|
||||
} == 3
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 14') do
|
||||
@@ -150,31 +166,37 @@ assert('BS Block 14') do
|
||||
yield
|
||||
end
|
||||
|
||||
iter1{
|
||||
jb = 2
|
||||
assert_equal(2) do
|
||||
iter1{
|
||||
jb = 2
|
||||
iter1{
|
||||
jb
|
||||
}
|
||||
jb
|
||||
}
|
||||
jb
|
||||
} == 2
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 15') do
|
||||
def m
|
||||
yield 1
|
||||
end
|
||||
m{|ib|
|
||||
ib*2
|
||||
} == 2
|
||||
assert_equal(2) do
|
||||
m{|ib|
|
||||
ib*2
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 16') do
|
||||
def m
|
||||
yield 12345, 67890
|
||||
end
|
||||
m{|ib,jb|
|
||||
ib*2+jb
|
||||
} == 92580
|
||||
assert_equal(92580) do
|
||||
m{|ib,jb|
|
||||
ib*2+jb
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 17') do
|
||||
@@ -183,9 +205,11 @@ assert('BS Block 17') do
|
||||
end
|
||||
|
||||
a = nil
|
||||
[iter{|a|
|
||||
a
|
||||
}, a] == [10, nil]
|
||||
assert_equal [10, nil] do
|
||||
[iter{|a|
|
||||
a
|
||||
}, a]
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 18') do
|
||||
@@ -193,11 +217,13 @@ assert('BS Block 18') do
|
||||
yield 10
|
||||
end
|
||||
|
||||
iter{|a|
|
||||
assert_equal(21) do
|
||||
iter{|a|
|
||||
a + 1
|
||||
} + a
|
||||
} == 21
|
||||
iter{|a|
|
||||
a + 1
|
||||
} + a
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 19') do
|
||||
@@ -206,9 +232,11 @@ assert('BS Block 19') do
|
||||
end
|
||||
|
||||
a = b = c = d = nil
|
||||
iter{|a, b, c, d|
|
||||
[a, b, c, d]
|
||||
} + [a, b, c, d] == [10, 20, 30, 40, nil, nil, nil, nil]
|
||||
assert_equal([10, 20, 30, 40, nil, nil, nil, nil]) do
|
||||
iter{|a, b, c, d|
|
||||
[a, b, c, d]
|
||||
} + [a, b, c, d]
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 20') do
|
||||
@@ -217,9 +245,11 @@ assert('BS Block 20') do
|
||||
end
|
||||
|
||||
a = b = nil
|
||||
iter{|a, b, c, d|
|
||||
[a, b, c, d]
|
||||
} + [a, b] == [10, 20, 30, 40, nil, nil]
|
||||
assert_equal([10, 20, 30, 40, nil, nil]) do
|
||||
iter{|a, b, c, d|
|
||||
[a, b, c, d]
|
||||
} + [a, b]
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 21') do
|
||||
@@ -227,9 +257,11 @@ assert('BS Block 21') do
|
||||
yield 1, 2
|
||||
end
|
||||
|
||||
iter{|a, *b|
|
||||
[a, b]
|
||||
} == [1, [2]]
|
||||
assert_equal([1, [2]]) do
|
||||
iter{|a, *b|
|
||||
[a, b]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 22') do
|
||||
@@ -237,9 +269,11 @@ assert('BS Block 22') do
|
||||
yield 1, 2
|
||||
end
|
||||
|
||||
iter{|*a|
|
||||
[a]
|
||||
} == [[1, 2]]
|
||||
assert_equal([[1, 2]]) do
|
||||
iter{|*a|
|
||||
[a]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 23') do
|
||||
@@ -247,40 +281,48 @@ assert('BS Block 23') do
|
||||
yield 1, 2
|
||||
end
|
||||
|
||||
iter{|a, b, *c|
|
||||
[a, b, c]
|
||||
} == [1, 2, []]
|
||||
assert_equal([1, 2, []]) do
|
||||
iter{|a, b, *c|
|
||||
[a, b, c]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 24') do
|
||||
def m
|
||||
yield
|
||||
end
|
||||
m{
|
||||
1
|
||||
} == 1
|
||||
assert_equal(1) do
|
||||
m{
|
||||
1
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 25') do
|
||||
def m
|
||||
yield 123
|
||||
end
|
||||
m{|ib|
|
||||
m{|jb|
|
||||
ib*jb
|
||||
assert_equal(15129) do
|
||||
m{|ib|
|
||||
m{|jb|
|
||||
ib*jb
|
||||
}
|
||||
}
|
||||
} == 15129
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 26') do
|
||||
def m a
|
||||
yield a
|
||||
end
|
||||
m(1){|ib|
|
||||
m(2){|jb|
|
||||
ib*jb
|
||||
assert_equal(2) do
|
||||
m(1){|ib|
|
||||
m(2){|jb|
|
||||
ib*jb
|
||||
}
|
||||
}
|
||||
} == 2
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 27') do
|
||||
@@ -289,13 +331,15 @@ assert('BS Block 27') do
|
||||
2.times{|jb|
|
||||
sum += ib + jb
|
||||
}}
|
||||
sum == 9
|
||||
assert_equal sum, 9
|
||||
end
|
||||
|
||||
assert('BS Block 28') do
|
||||
3.times{|bl|
|
||||
break 10
|
||||
} == 10
|
||||
assert_equal(10) do
|
||||
3.times{|bl|
|
||||
break 10
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 29') do
|
||||
@@ -303,9 +347,11 @@ assert('BS Block 29') do
|
||||
yield 1,2,3
|
||||
end
|
||||
|
||||
iter{|i, j|
|
||||
[i, j]
|
||||
} == [1, 2]
|
||||
assert_equal([1, 2]) do
|
||||
iter{|i, j|
|
||||
[i, j]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block 30') do
|
||||
@@ -313,23 +359,25 @@ assert('BS Block 30') do
|
||||
yield 1
|
||||
end
|
||||
|
||||
iter{|i, j|
|
||||
[i, j]
|
||||
} == [1, nil]
|
||||
assert_equal([1, nil]) do
|
||||
iter{|i, j|
|
||||
[i, j]
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
assert('BS Block [ruby-dev:31147]') do
|
||||
def m
|
||||
yield
|
||||
end
|
||||
m{|&b| b} == nil
|
||||
assert_nil m{|&b| b}
|
||||
end
|
||||
|
||||
assert('BS Block [ruby-dev:31160]') do
|
||||
def m()
|
||||
yield
|
||||
end
|
||||
m {|(v,(*))|} == nil
|
||||
assert_nil m {|(v,(*))|}
|
||||
end
|
||||
|
||||
assert('BS Block [issue #750]') do
|
||||
@@ -337,25 +385,26 @@ assert('BS Block [issue #750]') do
|
||||
yield
|
||||
end
|
||||
args = [1, 2, 3]
|
||||
m(*args){ 1 } == 1
|
||||
assert_equal m(*args){ 1 }, 1
|
||||
end
|
||||
|
||||
assert('BS Block 31') do
|
||||
def m()
|
||||
yield
|
||||
end
|
||||
m {|((*))|} == nil
|
||||
assert_nil m {|((*))|}
|
||||
end
|
||||
|
||||
assert('BS Block [ruby-dev:31440]') do
|
||||
def m
|
||||
yield [0]
|
||||
end
|
||||
m{|v, &b| v} == [0]
|
||||
assert_equal m{|v, &b| v}, [0]
|
||||
end
|
||||
|
||||
assert('BS Block 32') do
|
||||
r = false; 1.times{|&b| r = b}; r.class == NilClass
|
||||
r = false; 1.times{|&b| r = b}
|
||||
assert_equal r.class, NilClass
|
||||
end
|
||||
|
||||
assert('BS Block [ruby-core:14395]') do
|
||||
@@ -394,7 +443,7 @@ assert('BS Block [ruby-core:14395]') do
|
||||
end
|
||||
end
|
||||
t = Controller.new
|
||||
t.test_for_bug
|
||||
assert_true t.test_for_bug
|
||||
end
|
||||
|
||||
assert("BS Block 33") do
|
||||
@@ -408,7 +457,7 @@ assert("BS Block 33") do
|
||||
:bad
|
||||
end
|
||||
end
|
||||
TestReturnFromNestedBlock.test == :ok
|
||||
assert_equal TestReturnFromNestedBlock.test, :ok
|
||||
end
|
||||
|
||||
assert("BS Block 34") do
|
||||
@@ -422,7 +471,7 @@ assert("BS Block 34") do
|
||||
:bad
|
||||
end
|
||||
end
|
||||
TestReturnFromNestedBlock_BSBlock34.test == :ok
|
||||
assert_equal TestReturnFromNestedBlock_BSBlock34.test, :ok
|
||||
end
|
||||
|
||||
assert("BS Block 35") do
|
||||
@@ -436,5 +485,5 @@ assert("BS Block 35") do
|
||||
:bad
|
||||
end
|
||||
end
|
||||
TestReturnFromNestedBlock_BSBlock35.test == :ok
|
||||
assert_equal TestReturnFromNestedBlock_BSBlock35.test, :ok
|
||||
end
|
||||
|
||||
@@ -2,37 +2,37 @@
|
||||
# Bootstrap test for literals
|
||||
|
||||
assert('BS Literal 1') do
|
||||
true == true
|
||||
assert_true true
|
||||
end
|
||||
|
||||
assert('BS Literal 2') do
|
||||
TrueClass == true.class
|
||||
assert_equal TrueClass, true.class
|
||||
end
|
||||
|
||||
assert('BS Literal 3') do
|
||||
false == false
|
||||
assert_false false
|
||||
end
|
||||
|
||||
assert('BS Literal 4') do
|
||||
FalseClass == false.class
|
||||
assert_equal FalseClass, false.class
|
||||
end
|
||||
|
||||
assert('BS Literal 5') do
|
||||
'nil' == nil.inspect
|
||||
assert_equal 'nil', nil.inspect
|
||||
end
|
||||
|
||||
assert('BS Literal 6') do
|
||||
NilClass == nil.class
|
||||
assert_equal NilClass, nil.class
|
||||
end
|
||||
|
||||
assert('BS Literal 7') do
|
||||
Symbol == :sym.class
|
||||
assert_equal Symbol, :sym.class
|
||||
end
|
||||
|
||||
assert('BS Literal 8') do
|
||||
1234 == 1234
|
||||
assert_equal 1234, 1234
|
||||
end
|
||||
|
||||
assert('BS Literal 9') do
|
||||
Fixnum == 1234.class
|
||||
assert_equal Fixnum, 1234.class
|
||||
end
|
||||
|
||||
+47
-25
@@ -2,51 +2,51 @@
|
||||
# Float ISO Test
|
||||
|
||||
assert('Float', '15.2.9') do
|
||||
Float.class == Class
|
||||
assert_equal Float.class, Class
|
||||
end
|
||||
|
||||
assert('Float superclass', '15.2.9.2') do
|
||||
Float.superclass == Numeric
|
||||
assert_equal Float.superclass, Numeric
|
||||
end
|
||||
|
||||
assert('Float#+', '15.2.9.3.1') do
|
||||
a = 3.123456788 + 0.000000001
|
||||
b = 3.123456789 + 1
|
||||
|
||||
check_float(a, 3.123456789) and
|
||||
check_float(b, 4.123456789)
|
||||
assert_float(a, 3.123456789)
|
||||
assert_float(b, 4.123456789)
|
||||
end
|
||||
|
||||
assert('Float#-', '15.2.9.3.2') do
|
||||
a = 3.123456790 - 0.000000001
|
||||
b = 5.123456789 - 1
|
||||
|
||||
check_float(a, 3.123456789) and
|
||||
check_float(b, 4.123456789)
|
||||
assert_float(a, 3.123456789)
|
||||
assert_float(b, 4.123456789)
|
||||
end
|
||||
|
||||
assert('Float#*', '15.2.9.3.3') do
|
||||
a = 3.125 * 3.125
|
||||
b = 3.125 * 1
|
||||
|
||||
check_float(a, 9.765625) and
|
||||
check_float(b, 3.125)
|
||||
assert_float(a, 9.765625)
|
||||
assert_float(b, 3.125)
|
||||
end
|
||||
|
||||
assert('Float#/', '15.2.9.3.4') do
|
||||
a = 3.123456789 / 3.123456789
|
||||
b = 3.123456789 / 1
|
||||
|
||||
check_float(a, 1.0) and
|
||||
check_float(b, 3.123456789)
|
||||
assert_float(a, 1.0)
|
||||
assert_float(b, 3.123456789)
|
||||
end
|
||||
|
||||
assert('Float#%', '15.2.9.3.5') do
|
||||
a = 3.125 % 3.125
|
||||
b = 3.125 % 1
|
||||
|
||||
check_float(a, 0.0) and
|
||||
check_float(b, 0.125)
|
||||
assert_float(a, 0.0)
|
||||
assert_float(b, 0.125)
|
||||
end
|
||||
|
||||
assert('Float#<=>', '15.2.9.3.6') do
|
||||
@@ -56,12 +56,16 @@ assert('Float#<=>', '15.2.9.3.6') do
|
||||
a2 = 3.125 <=> 3
|
||||
c2 = 3.125 <=> 4
|
||||
|
||||
a == 1 and b == 0 and c == -1 and
|
||||
a2 == 1 and c2 == -1
|
||||
assert_equal a, 1
|
||||
assert_equal b, 0
|
||||
assert_equal c, -1
|
||||
assert_equal a2, 1
|
||||
assert_equal c2, -1
|
||||
end
|
||||
|
||||
assert('Float#==', '15.2.9.3.7') do
|
||||
3.1 == 3.1 and not 3.1 == 3.2
|
||||
assert_true 3.1 == 3.1
|
||||
assert_false 3.1 == 3.2
|
||||
end
|
||||
|
||||
assert('Float#ceil', '15.2.9.3.8') do
|
||||
@@ -69,12 +73,16 @@ assert('Float#ceil', '15.2.9.3.8') do
|
||||
b = 3.0.ceil
|
||||
c = -3.123456789.ceil
|
||||
d = -3.0.ceil
|
||||
a == 4 and b == 3 and c == -3 and d == -3
|
||||
|
||||
assert_equal a, 4
|
||||
assert_equal b, 3
|
||||
assert_equal c, -3
|
||||
assert_equal d, -3
|
||||
end
|
||||
|
||||
assert('Float#finite?', '15.2.9.3.9') do
|
||||
3.123456789.finite? and
|
||||
not (1.0 / 0.0).finite?
|
||||
assert_true 3.123456789.finite?
|
||||
assert_false (1.0 / 0.0).finite?
|
||||
end
|
||||
|
||||
assert('Float#floor', '15.2.9.3.10') do
|
||||
@@ -82,7 +90,11 @@ assert('Float#floor', '15.2.9.3.10') do
|
||||
b = 3.0.floor
|
||||
c = -3.123456789.floor
|
||||
d = -3.0.floor
|
||||
a == 3 and b == 3 and c == -4 and d == -3
|
||||
|
||||
assert_equal a, 3
|
||||
assert_equal b, 3
|
||||
assert_equal c, -4
|
||||
assert_equal d, -3
|
||||
end
|
||||
|
||||
assert('Float#infinite?', '15.2.9.3.11') do
|
||||
@@ -90,7 +102,9 @@ assert('Float#infinite?', '15.2.9.3.11') do
|
||||
b = (1.0 / 0.0).infinite?
|
||||
c = (-1.0 / 0.0).infinite?
|
||||
|
||||
a == nil and b == 1 and c == -1
|
||||
assert_nil a
|
||||
assert_equal b, 1
|
||||
assert_equal c, -1
|
||||
end
|
||||
|
||||
assert('Float#round', '15.2.9.3.12') do
|
||||
@@ -104,20 +118,28 @@ assert('Float#round', '15.2.9.3.12') do
|
||||
h = 3.423456789.round(1)
|
||||
i = 3.423456789.round(3)
|
||||
|
||||
a == 3 and b == 4 and c == 3 and d == -3 and e == -4 and
|
||||
f == 12350 and g == 3 and check_float(h, 3.4) and check_float(i, 3.423)
|
||||
assert_equal a, 3
|
||||
assert_equal b, 4
|
||||
assert_equal c, 3
|
||||
assert_equal d, -3
|
||||
assert_equal e, -4
|
||||
assert_equal f, 12350
|
||||
assert_equal g, 3
|
||||
assert_float(h, 3.4)
|
||||
assert_float(i, 3.423)
|
||||
end
|
||||
|
||||
assert('Float#to_f', '15.2.9.3.13') do
|
||||
a = 3.123456789
|
||||
|
||||
check_float(a.to_f, a)
|
||||
assert_float(a.to_f, a)
|
||||
end
|
||||
|
||||
assert('Float#to_i', '15.2.9.3.14') do
|
||||
3.123456789.to_i == 3
|
||||
assert_equal 3.123456789.to_i, 3
|
||||
end
|
||||
|
||||
assert('Float#truncate', '15.2.9.3.15') do
|
||||
3.123456789.truncate == 3 and -3.1.truncate == -3
|
||||
assert_equal 3.123456789.truncate, 3
|
||||
assert_equal(-3.1.truncate, -3)
|
||||
end
|
||||
|
||||
+10
-10
@@ -1,15 +1,15 @@
|
||||
# Not ISO specified
|
||||
|
||||
assert('GC.enable') do
|
||||
GC.disable == false
|
||||
GC.enable == true
|
||||
GC.enable == false
|
||||
assert_equal GC.disable, false
|
||||
assert_equal GC.enable, true
|
||||
assert_equal GC.enable, false
|
||||
end
|
||||
|
||||
assert('GC.disable') do
|
||||
begin
|
||||
GC.disable == false
|
||||
GC.disable == true
|
||||
assert_equal GC.disable, false
|
||||
assert_equal GC.disable, true
|
||||
ensure
|
||||
GC.enable
|
||||
end
|
||||
@@ -18,7 +18,7 @@ end
|
||||
assert('GC.interval_ratio=') do
|
||||
origin = GC.interval_ratio
|
||||
begin
|
||||
(GC.interval_ratio = 150) == 150
|
||||
assert_equal (GC.interval_ratio = 150), 150
|
||||
ensure
|
||||
GC.interval_ratio = origin
|
||||
end
|
||||
@@ -27,7 +27,7 @@ end
|
||||
assert('GC.step_ratio=') do
|
||||
origin = GC.step_ratio
|
||||
begin
|
||||
(GC.step_ratio = 150) == 150
|
||||
assert_equal (GC.step_ratio = 150), 150
|
||||
ensure
|
||||
GC.step_ratio = origin
|
||||
end
|
||||
@@ -36,9 +36,9 @@ end
|
||||
assert('GC.generational_mode=') do
|
||||
origin = GC.generational_mode
|
||||
begin
|
||||
(GC.generational_mode = false) == false
|
||||
(GC.generational_mode = true) == true
|
||||
(GC.generational_mode = true) == true
|
||||
assert_equal (GC.generational_mode = false), false
|
||||
assert_equal (GC.generational_mode = true), true
|
||||
assert_equal (GC.generational_mode = true), true
|
||||
ensure
|
||||
GC.generational_mode = origin
|
||||
end
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
# IndexError ISO Test
|
||||
|
||||
assert('IndexError', '15.2.33') do
|
||||
IndexError.class == Class
|
||||
assert_equal IndexError.class, Class
|
||||
end
|
||||
|
||||
assert('IndexError superclass', '15.2.33.2') do
|
||||
IndexError.superclass == StandardError
|
||||
assert_equal IndexError.superclass, StandardError
|
||||
end
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ assert('Literals Numerical', '8.7.6.2') do
|
||||
0xff == 255 and 0Xff == 255 and
|
||||
# decimal
|
||||
0d999 == 999 and 0D999 == 999 and
|
||||
# decimal seperator
|
||||
# decimal separator
|
||||
10_000_000 == 10000000 and 1_0 == 10 and
|
||||
# integer with exponent
|
||||
1e1 == 10.0 and 1e-1 == 0.1 and 1e+1 == 10.0
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
##
|
||||
# LocalJumpError ISO Test
|
||||
|
||||
assert('LocalJumoError', '15.2.25') do
|
||||
begin
|
||||
assert('LocalJumpError', '15.2.25') do
|
||||
assert_equal LocalJumpError.class, Class
|
||||
assert_raise LocalJumpError do
|
||||
# this will cause an exception due to the wrong location
|
||||
retry
|
||||
rescue => e1
|
||||
end
|
||||
LocalJumpError.class == Class and e1.class == LocalJumpError
|
||||
end
|
||||
|
||||
# TODO 15.2.25.2.1 LocalJumpError#exit_value
|
||||
|
||||
+6
-6
@@ -2,11 +2,11 @@
|
||||
# NameError ISO Test
|
||||
|
||||
assert('NameError', '15.2.31') do
|
||||
NameError.class == Class
|
||||
assert_equal NameError.class, Class
|
||||
end
|
||||
|
||||
assert('NameError superclass', '15.2.31.2') do
|
||||
NameError.superclass == StandardError
|
||||
assert_equal NameError.superclass, StandardError
|
||||
end
|
||||
|
||||
assert('NameError#name', '15.2.31.2.1') do
|
||||
@@ -20,13 +20,13 @@ assert('NameError#name', '15.2.31.2.1') do
|
||||
$test_dummy_result = e.name
|
||||
end
|
||||
|
||||
$test_dummy_result == :bar
|
||||
assert_equal $test_dummy_result, :bar
|
||||
end
|
||||
|
||||
assert('NameError#initialize', '15.2.31.2.2') do
|
||||
e = NameError.new('a', :foo)
|
||||
|
||||
e.class == NameError and
|
||||
e.message == 'a' and
|
||||
e.name == :foo
|
||||
assert_equal e.class, NameError
|
||||
assert_equal e.message, 'a'
|
||||
assert_equal e.name, :foo
|
||||
end
|
||||
|
||||
+10
-6
@@ -2,25 +2,29 @@
|
||||
# NilClass ISO Test
|
||||
|
||||
assert('NilClass', '15.2.4') do
|
||||
NilClass.class == Class
|
||||
assert_equal NilClass.class, Class
|
||||
end
|
||||
|
||||
assert('NilClass#&', '15.2.4.3.1') do
|
||||
not nil.&(true) and not nil.&(nil)
|
||||
assert_false nil.&(true)
|
||||
assert_false nil.&(nil)
|
||||
end
|
||||
|
||||
assert('NilClass#^', '15.2.4.3.2') do
|
||||
nil.^(true) and not nil.^(false)
|
||||
assert_true nil.^(true)
|
||||
assert_false nil.^(false)
|
||||
end
|
||||
|
||||
assert('NilClass#|', '15.2.4.3.3') do
|
||||
nil.|(true) and not nil.|(false)
|
||||
assert_true nil.|(true)
|
||||
assert_false nil.|(false)
|
||||
end
|
||||
|
||||
assert('NilClass#nil?', '15.2.4.3.4') do
|
||||
nil.nil?
|
||||
assert_true nil.nil?
|
||||
end
|
||||
|
||||
assert('NilClass#to_s', '15.2.4.3.5') do
|
||||
nil.to_s == ''
|
||||
assert_equal nil.to_s, ''
|
||||
end
|
||||
|
||||
|
||||
@@ -2,17 +2,12 @@
|
||||
# NoMethodError ISO Test
|
||||
|
||||
assert('NoMethodError', '15.2.32') do
|
||||
e2 = nil
|
||||
begin
|
||||
NoMethodError.class == Class
|
||||
assert_raise NoMethodError do
|
||||
doesNotExistAsAMethodNameForVerySure("")
|
||||
rescue => e1
|
||||
e2 = e1
|
||||
end
|
||||
|
||||
NoMethodError.class == Class and e2.class == NoMethodError
|
||||
end
|
||||
|
||||
assert('NoMethodError superclass', '15.2.32.2') do
|
||||
NoMethodError.superclass == NameError
|
||||
assert_equal NoMethodError.superclass, NameError
|
||||
end
|
||||
|
||||
|
||||
+7
-6
@@ -2,27 +2,28 @@
|
||||
# Numeric ISO Test
|
||||
|
||||
assert('Numeric', '15.2.7') do
|
||||
Numeric.class == Class
|
||||
assert_equal Numeric.class, Class
|
||||
end
|
||||
|
||||
assert('Numeric superclass', '15.2.7.2') do
|
||||
Numeric.superclass == Object
|
||||
assert_equal Numeric.superclass, Object
|
||||
end
|
||||
|
||||
assert('Numeric#+@', '15.2.7.4.1') do
|
||||
+1 == +1
|
||||
assert_equal(+1, +1)
|
||||
end
|
||||
|
||||
assert('Numeric#-@', '15.2.7.4.2') do
|
||||
-1 == -1
|
||||
assert_equal(-1, -1)
|
||||
end
|
||||
|
||||
assert('Numeric#abs', '15.2.7.4.3') do
|
||||
1.abs == 1 and -1.abs == 1.0
|
||||
assert_equal(1.abs, 1)
|
||||
assert_equal(-1.abs, 1.0)
|
||||
end
|
||||
|
||||
# Not ISO specified
|
||||
|
||||
assert('Numeric#**') do
|
||||
2.0**3 == 8.0
|
||||
assert_equal 2.0**3, 8.0
|
||||
end
|
||||
|
||||
+2
-2
@@ -2,10 +2,10 @@
|
||||
# Object ISO Test
|
||||
|
||||
assert('Object', '15.2.1') do
|
||||
Object.class == Class
|
||||
assert_equal Object.class, Class
|
||||
end
|
||||
|
||||
assert('Object superclass', '15.2.1.2') do
|
||||
Object.superclass == BasicObject
|
||||
assert_equal Object.superclass, BasicObject
|
||||
end
|
||||
|
||||
|
||||
+12
-13
@@ -2,25 +2,19 @@
|
||||
# Proc ISO Test
|
||||
|
||||
assert('Proc', '15.2.17') do
|
||||
Proc.class == Class
|
||||
assert_equal Proc.class, Class
|
||||
end
|
||||
|
||||
assert('Proc superclass', '15.2.17.2') do
|
||||
Proc.superclass == Object
|
||||
assert_equal Proc.superclass, Object
|
||||
end
|
||||
|
||||
assert('Proc.new', '15.2.17.3.1') do
|
||||
a = nil
|
||||
|
||||
begin
|
||||
assert_raise ArgumentError do
|
||||
Proc.new
|
||||
rescue => e
|
||||
a = e
|
||||
end
|
||||
|
||||
b = Proc.new {}
|
||||
|
||||
a.class == ArgumentError and b.class == Proc
|
||||
assert_equal (Proc.new {}).class, Proc
|
||||
end
|
||||
|
||||
assert('Proc#[]', '15.2.17.4.1') do
|
||||
@@ -32,7 +26,8 @@ assert('Proc#[]', '15.2.17.4.1') do
|
||||
b2 = Proc.new { |i| a2 += i }
|
||||
b2.[](5)
|
||||
|
||||
a == 1 and a2 == 5
|
||||
assert_equal a, 1
|
||||
assert_equal a2, 5
|
||||
end
|
||||
|
||||
assert('Proc#arity', '15.2.17.4.2') do
|
||||
@@ -41,7 +36,10 @@ assert('Proc#arity', '15.2.17.4.2') do
|
||||
c = Proc.new {|x=0, y|}.arity
|
||||
d = Proc.new {|(x, y), z=0|}.arity
|
||||
|
||||
a == 2 and b == -3 and c == 1 and d == 1
|
||||
assert_equal a, 2
|
||||
assert_equal b, -3
|
||||
assert_equal c, 1
|
||||
assert_equal d, 1
|
||||
end
|
||||
|
||||
assert('Proc#call', '15.2.17.4.3') do
|
||||
@@ -53,5 +51,6 @@ assert('Proc#call', '15.2.17.4.3') do
|
||||
b2 = Proc.new { |i| a2 += i }
|
||||
b2.call(5)
|
||||
|
||||
a == 1 and a2 == 5
|
||||
assert_equal a, 1
|
||||
assert_equal a2, 5
|
||||
end
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
# RangeError ISO Test
|
||||
|
||||
assert('RangeError', '15.2.26') do
|
||||
RangeError.class == Class
|
||||
assert_equal RangeError.class, Class
|
||||
end
|
||||
|
||||
assert('RangeError superclass', '15.2.26.2') do
|
||||
RangeError.superclass == StandardError
|
||||
assert_equal RangeError.superclass, StandardError
|
||||
end
|
||||
|
||||
|
||||
@@ -2,5 +2,5 @@
|
||||
# RuntimeError ISO Test
|
||||
|
||||
assert('RuntimeError', '15.2.28') do
|
||||
RuntimeError.class == Class
|
||||
assert_equal RuntimeError.class, Class
|
||||
end
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
# StandardError ISO Test
|
||||
|
||||
assert('StandardError', '15.2.23') do
|
||||
StandardError.class == Class
|
||||
assert_equal StandardError.class, Class
|
||||
end
|
||||
|
||||
assert('StandardError superclass', '15.2.23.2') do
|
||||
StandardError.superclass == Exception
|
||||
assert_equal StandardError.superclass, Exception
|
||||
end
|
||||
|
||||
|
||||
+7
-6
@@ -2,25 +2,26 @@
|
||||
# Symbol ISO Test
|
||||
|
||||
assert('Symbol', '15.2.11') do
|
||||
Symbol.class == Class
|
||||
assert_equal Symbol.class, Class
|
||||
end
|
||||
|
||||
assert('Symbol superclass', '15.2.11.2') do
|
||||
Symbol.superclass == Object
|
||||
assert_equal Symbol.superclass, Object
|
||||
end
|
||||
|
||||
assert('Symbol#===', '15.2.11.3.1') do
|
||||
:abc === :abc and not :abc === :cba
|
||||
assert_true :abc == :abc
|
||||
assert_false :abc == :cba
|
||||
end
|
||||
|
||||
assert('Symbol#id2name', '15.2.11.3.2') do
|
||||
:abc.id2name == 'abc'
|
||||
assert_equal :abc.id2name, 'abc'
|
||||
end
|
||||
|
||||
assert('Symbol#to_s', '15.2.11.3.3') do
|
||||
:abc.to_s == 'abc'
|
||||
assert_equal :abc.to_s, 'abc'
|
||||
end
|
||||
|
||||
assert('Symbol#to_sym', '15.2.11.3.4') do
|
||||
:abc.to_sym == :abc
|
||||
assert_equal :abc.to_sym, :abc
|
||||
end
|
||||
|
||||
+10
-7
@@ -2,29 +2,32 @@
|
||||
# TrueClass ISO Test
|
||||
|
||||
assert('TrueClass', '15.2.5') do
|
||||
TrueClass.class == Class
|
||||
assert_equal TrueClass.class, Class
|
||||
end
|
||||
|
||||
assert('TrueClass superclass', '15.2.5.2') do
|
||||
TrueClass.superclass == Object
|
||||
assert_equal TrueClass.superclass, Object
|
||||
end
|
||||
|
||||
assert('TrueClass true', '15.2.5.1') do
|
||||
true
|
||||
assert_true true
|
||||
end
|
||||
|
||||
assert('TrueClass#&', '15.2.5.3.1') do
|
||||
true.&(true) and not true.&(false)
|
||||
assert_true true.&(true)
|
||||
assert_false true.&(false)
|
||||
end
|
||||
|
||||
assert('TrueClass#^', '15.2.5.3.2') do
|
||||
not true.^(true) and true.^(false)
|
||||
assert_false true.^(true)
|
||||
assert_true true.^(false)
|
||||
end
|
||||
|
||||
assert('TrueClass#to_s', '15.2.5.3.3') do
|
||||
true.to_s == 'true'
|
||||
assert_equal true.to_s, 'true'
|
||||
end
|
||||
|
||||
assert('TrueClass#|', '15.2.5.3.4') do
|
||||
true.|(true) and true.|(false)
|
||||
assert_true true.|(true)
|
||||
assert_true true.|(false)
|
||||
end
|
||||
|
||||
+2
-2
@@ -2,10 +2,10 @@
|
||||
# TypeError ISO Test
|
||||
|
||||
assert('TypeError', '15.2.29') do
|
||||
TypeError.class == Class
|
||||
assert_equal TypeError.class, Class
|
||||
end
|
||||
|
||||
assert('TypeError superclass', '15.2.29.2') do
|
||||
TypeError.superclass == StandardError
|
||||
assert_equal TypeError.superclass, StandardError
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user