Commit 9a0fba7f authored by Yukihiro "Matz" Matsumoto's avatar Yukihiro "Matz" Matsumoto

Merge pull request #1128 from monaka/pr-add-iso-confomance-tests-20130402

Add ISO confomance tests
parents 6bd49a3d 4bb7243c
...@@ -272,7 +272,7 @@ assert('Array#unshift', '15.2.12.5.30') do ...@@ -272,7 +272,7 @@ assert('Array#unshift', '15.2.12.5.30') do
a == [1,2,3] and b == [1,2,3] and c == [0,1,2,3] and d == [0,1,2,3] a == [1,2,3] and b == [1,2,3] and c == [0,1,2,3] and d == [0,1,2,3]
end end
assert('Array#to_s', '15.2.12.5.31') do assert('Array#to_s', '15.2.12.5.31 / 15.2.12.5.32') do
a = [2, 3, 4, 5] a = [2, 3, 4, 5]
r1 = a.to_s r1 = a.to_s
r2 = a.inspect r2 = a.inspect
...@@ -288,6 +288,20 @@ assert('Array#==', '15.2.12.5.33') do ...@@ -288,6 +288,20 @@ assert('Array#==', '15.2.12.5.33') do
r1 == false and r2 == true and r3 == false r1 == false and r2 == true and r3 == false
end end
assert('Array#eql?', '15.2.12.5.34') do
a1 = [ 1, 2, 3 ]
a2 = [ 1, 2, 3 ]
a3 = [ 1.0, 2.0, 3.0 ]
(a1.eql? a2) and (not a1.eql? a3)
end
assert('Array#hash', '15.2.12.5.35') do
a = [ 1, 2, 3 ]
a.hash.is_a? Integer
end
assert('Array#<=>', '15.2.12.5.36') do assert('Array#<=>', '15.2.12.5.36') do
r1 = [ "a", "a", "c" ] <=> [ "a", "b", "c" ] #=> -1 r1 = [ "a", "a", "c" ] <=> [ "a", "b", "c" ] #=> -1
r2 = [ 1, 2, 3, 4, 5, 6 ] <=> [ 1, 2 ] #=> +1 r2 = [ 1, 2, 3, 4, 5, 6 ] <=> [ 1, 2 ] #=> +1
......
...@@ -9,6 +9,26 @@ assert('Class superclass', '15.2.3.2') do ...@@ -9,6 +9,26 @@ assert('Class superclass', '15.2.3.2') do
Class.superclass == Module Class.superclass == Module
end end
# Class#initialize '15.2.3.3.1' is tested in Class#new
assert('Class#initialize_copy', '15.2.3.3.2') do
class TestClass
attr_accessor :n
def initialize(n)
@n = n
end
def initialize_copy(obj)
@n = n
end
end
c1 = TestClass.new('Foo')
c2 = c1.dup
c3 = TestClass.new('Bar')
c1.n == c2.n and c1.n != c3.n
end
assert('Class#new', '15.2.3.3.3') do assert('Class#new', '15.2.3.3.3') do
# at the moment no exception on singleton class # at the moment no exception on singleton class
#e1 = nil #e1 = nil
......
assert('<', '15.3.3.2.1') do assert('Comparable#<', '15.3.3.2.1') do
class Foo class Foo
include Comparable include Comparable
def <=>(x) def <=>(x)
...@@ -10,7 +10,7 @@ assert('<', '15.3.3.2.1') do ...@@ -10,7 +10,7 @@ assert('<', '15.3.3.2.1') do
(Foo.new < Foo.new) == false (Foo.new < Foo.new) == false
end end
assert('<=', '15.3.3.2.2') do assert('Comparable#<=', '15.3.3.2.2') do
class Foo class Foo
include Comparable include Comparable
def <=>(x) def <=>(x)
...@@ -21,7 +21,7 @@ assert('<=', '15.3.3.2.2') do ...@@ -21,7 +21,7 @@ assert('<=', '15.3.3.2.2') do
(Foo.new <= Foo.new) == true (Foo.new <= Foo.new) == true
end end
assert('==', '15.3.3.2.3') do assert('Comparable#==', '15.3.3.2.3') do
class Foo class Foo
include Comparable include Comparable
def <=>(x) def <=>(x)
...@@ -32,7 +32,7 @@ assert('==', '15.3.3.2.3') do ...@@ -32,7 +32,7 @@ assert('==', '15.3.3.2.3') do
(Foo.new == Foo.new) == true (Foo.new == Foo.new) == true
end end
assert('>', '15.3.3.2.4') do assert('Comparable#>', '15.3.3.2.4') do
class Foo class Foo
include Comparable include Comparable
def <=>(x) def <=>(x)
...@@ -43,7 +43,7 @@ assert('>', '15.3.3.2.4') do ...@@ -43,7 +43,7 @@ assert('>', '15.3.3.2.4') do
(Foo.new > Foo.new) == false (Foo.new > Foo.new) == false
end end
assert('>=', '15.3.3.2.5') do assert('Comparable#>=', '15.3.3.2.5') do
class Foo class Foo
include Comparable include Comparable
def <=>(x) def <=>(x)
......
...@@ -138,7 +138,18 @@ assert('Hash#include?', '15.2.13.4.15') do ...@@ -138,7 +138,18 @@ assert('Hash#include?', '15.2.13.4.15') do
a.include?('abc_key') and not b.include?('cba') a.include?('abc_key') and not b.include?('cba')
end end
assert('Hash#initialize copy', '15.2.13.4.17') do assert('Hash#initialize', '15.2.13.4.16') do
# Testing initialize by new.
h = Hash.new
h2 = Hash.new(:not_found)
h.is_a? Hash and
h == { } and
h["hello"] == nil and
h2["hello"] == :not_found
end
assert('Hash#initialize_copy', '15.2.13.4.17') do
a = { 'abc_key' => 'abc_value' } a = { 'abc_key' => 'abc_value' }
b = Hash.new.initialize_copy(a) b = Hash.new.initialize_copy(a)
......
...@@ -23,6 +23,8 @@ assert('Kernel.block_given?', '15.3.1.2.2') do ...@@ -23,6 +23,8 @@ assert('Kernel.block_given?', '15.3.1.2.2') do
((bg_try do "block" end) == "block") ((bg_try do "block" end) == "block")
end end
# Kernel.eval is provided by the mruby-gem mrbgem. '15.3.1.2.3'
assert('Kernel.global_variables', '15.3.1.2.4') do assert('Kernel.global_variables', '15.3.1.2.4') do
Kernel.global_variables.class == Array Kernel.global_variables.class == Array
end end
...@@ -189,6 +191,8 @@ assert('Kernel#dup', '15.3.1.3.9') do ...@@ -189,6 +191,8 @@ assert('Kernel#dup', '15.3.1.3.9') do
c.respond_to?(:test) == false c.respond_to?(:test) == false
end end
# Kernel#eval is provided by mruby-eval mrbgem '15.3.1.3.12'
assert('Kernel#extend', '15.3.1.3.13') do assert('Kernel#extend', '15.3.1.3.13') do
class Test4ExtendClass class Test4ExtendClass
end end
...@@ -287,6 +291,10 @@ assert('Kernel#object_id', '15.3.1.3.33') do ...@@ -287,6 +291,10 @@ assert('Kernel#object_id', '15.3.1.3.33') do
object_id.class == Fixnum object_id.class == Fixnum
end end
# Kernel#p is defined in mruby-print mrbgem. '15.3.1.3.34'
# Kernel#print is defined in mruby-print mrbgem. '15.3.1.3.35'
assert('Kernel#private_methods', '15.3.1.3.36') do assert('Kernel#private_methods', '15.3.1.3.36') do
private_methods.class == Array private_methods.class == Array
end end
...@@ -299,6 +307,8 @@ assert('Kernel#public_methods', '15.3.1.3.38') do ...@@ -299,6 +307,8 @@ assert('Kernel#public_methods', '15.3.1.3.38') do
public_methods.class == Array public_methods.class == Array
end end
# Kernel#puts is defined in mruby-print mrbgem. '15.3.1.3.39'
assert('Kernel#raise', '15.3.1.3.40') do assert('Kernel#raise', '15.3.1.3.40') do
e_list = [] e_list = []
......
...@@ -129,6 +129,21 @@ assert('Module#const_get', '15.2.2.4.23') do ...@@ -129,6 +129,21 @@ assert('Module#const_get', '15.2.2.4.23') do
Test4ConstSet.const_get(:Const4Test4ConstSet) == 23 Test4ConstSet.const_get(:Const4Test4ConstSet) == 23
end end
assert('Module.constants', '15.2.2.4.24') do
$n = []
module TestA
Const = 1
end
class TestB
include TestA
Const2 = 1
$n = constants.sort
end
TestA.constants == [ :Const ] and
$n == [ :Const, :Const2 ]
end
assert('Module#include', '15.2.2.4.27') do assert('Module#include', '15.2.2.4.27') do
module Test4Include module Test4Include
Const4Include = 42 Const4Include = 42
......
...@@ -32,7 +32,7 @@ assert('String#==', '15.2.10.5.4') do ...@@ -32,7 +32,7 @@ assert('String#==', '15.2.10.5.4') do
'abc' == 'abc' and not 'abc' == 'cba' 'abc' == 'abc' and not 'abc' == 'cba'
end end
# TODO: SEGFAULT ATM assert('String#=~', '15.2.10.5.5') # 'String#=~', '15.2.10.5.5' will be tested in mrbgems.
assert('String#[]', '15.2.10.5.6') do assert('String#[]', '15.2.10.5.6') do
# length of args is 1 # length of args is 1
...@@ -49,7 +49,7 @@ assert('String#[]', '15.2.10.5.6') do ...@@ -49,7 +49,7 @@ assert('String#[]', '15.2.10.5.6') do
e1 = 'abc'[1, 2] e1 = 'abc'[1, 2]
# args is RegExp # args is RegExp
# TODO SEGFAULT ATM # It will be tested in mrbgems.
# args is String # args is String
a3 = 'abc'['bc'] a3 = 'abc'['bc']
...@@ -251,7 +251,7 @@ assert('String#length', '15.2.10.5.26') do ...@@ -251,7 +251,7 @@ assert('String#length', '15.2.10.5.26') do
'abc'.length == 3 'abc'.length == 3
end end
# TODO Broken ATM assert('String#match', '15.2.10.5.27') do # 'String#match', '15.2.10.5.27' will be tested in mrbgems.
assert('String#replace', '15.2.10.5.28') do assert('String#replace', '15.2.10.5.28') do
a = '' a = ''
...@@ -279,7 +279,7 @@ assert('String#rindex', '15.2.10.5.31') do ...@@ -279,7 +279,7 @@ assert('String#rindex', '15.2.10.5.31') do
'abcabc'.rindex('a', 1) == 0 and 'abcabc'.rindex('a', 4) == 3 'abcabc'.rindex('a', 1) == 0 and 'abcabc'.rindex('a', 4) == 3
end end
# TODO Broken ATM assert('String#scan', '15.2.10.5.32') do # 'String#scan', '15.2.10.5.32' will be tested in mrbgems.
assert('String#size', '15.2.10.5.33') do assert('String#size', '15.2.10.5.33') do
'abc'.size == 3 'abc'.size == 3
...@@ -303,7 +303,7 @@ assert('String#slice', '15.2.10.5.34') do ...@@ -303,7 +303,7 @@ assert('String#slice', '15.2.10.5.34') do
e11 = e1.slice(0) e11 = e1.slice(0)
# args is RegExp # args is RegExp
# TODO SEGFAULT ATM # It will be tested in mrbgems.
# args is String # args is String
a3 = 'abc'.slice('bc') a3 = 'abc'.slice('bc')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment