mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Merge pull request #1128 from monaka/pr-add-iso-confomance-tests-20130402
Add ISO confomance tests
This commit is contained in:
+15
-1
@@ -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]
|
||||
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]
|
||||
r1 = a.to_s
|
||||
r2 = a.inspect
|
||||
@@ -288,6 +288,20 @@ assert('Array#==', '15.2.12.5.33') do
|
||||
r1 == false and r2 == true and r3 == false
|
||||
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
|
||||
r1 = [ "a", "a", "c" ] <=> [ "a", "b", "c" ] #=> -1
|
||||
r2 = [ 1, 2, 3, 4, 5, 6 ] <=> [ 1, 2 ] #=> +1
|
||||
|
||||
@@ -9,6 +9,26 @@ assert('Class superclass', '15.2.3.2') do
|
||||
Class.superclass == Module
|
||||
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
|
||||
# at the moment no exception on singleton class
|
||||
#e1 = nil
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
assert('<', '15.3.3.2.1') do
|
||||
assert('Comparable#<', '15.3.3.2.1') do
|
||||
class Foo
|
||||
include Comparable
|
||||
def <=>(x)
|
||||
@@ -10,7 +10,7 @@ assert('<', '15.3.3.2.1') do
|
||||
(Foo.new < Foo.new) == false
|
||||
end
|
||||
|
||||
assert('<=', '15.3.3.2.2') do
|
||||
assert('Comparable#<=', '15.3.3.2.2') do
|
||||
class Foo
|
||||
include Comparable
|
||||
def <=>(x)
|
||||
@@ -21,7 +21,7 @@ assert('<=', '15.3.3.2.2') do
|
||||
(Foo.new <= Foo.new) == true
|
||||
end
|
||||
|
||||
assert('==', '15.3.3.2.3') do
|
||||
assert('Comparable#==', '15.3.3.2.3') do
|
||||
class Foo
|
||||
include Comparable
|
||||
def <=>(x)
|
||||
@@ -32,7 +32,7 @@ assert('==', '15.3.3.2.3') do
|
||||
(Foo.new == Foo.new) == true
|
||||
end
|
||||
|
||||
assert('>', '15.3.3.2.4') do
|
||||
assert('Comparable#>', '15.3.3.2.4') do
|
||||
class Foo
|
||||
include Comparable
|
||||
def <=>(x)
|
||||
@@ -43,7 +43,7 @@ assert('>', '15.3.3.2.4') do
|
||||
(Foo.new > Foo.new) == false
|
||||
end
|
||||
|
||||
assert('>=', '15.3.3.2.5') do
|
||||
assert('Comparable#>=', '15.3.3.2.5') do
|
||||
class Foo
|
||||
include Comparable
|
||||
def <=>(x)
|
||||
|
||||
+12
-1
@@ -138,7 +138,18 @@ assert('Hash#include?', '15.2.13.4.15') do
|
||||
a.include?('abc_key') and not b.include?('cba')
|
||||
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' }
|
||||
b = Hash.new.initialize_copy(a)
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ assert('Kernel.block_given?', '15.3.1.2.2') do
|
||||
((bg_try do "block" end) == "block")
|
||||
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
|
||||
Kernel.global_variables.class == Array
|
||||
end
|
||||
@@ -189,6 +191,8 @@ assert('Kernel#dup', '15.3.1.3.9') do
|
||||
c.respond_to?(:test) == false
|
||||
end
|
||||
|
||||
# Kernel#eval is provided by mruby-eval mrbgem '15.3.1.3.12'
|
||||
|
||||
assert('Kernel#extend', '15.3.1.3.13') do
|
||||
class Test4ExtendClass
|
||||
end
|
||||
@@ -287,6 +291,10 @@ assert('Kernel#object_id', '15.3.1.3.33') do
|
||||
object_id.class == Fixnum
|
||||
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
|
||||
private_methods.class == Array
|
||||
end
|
||||
@@ -299,6 +307,8 @@ assert('Kernel#public_methods', '15.3.1.3.38') do
|
||||
public_methods.class == Array
|
||||
end
|
||||
|
||||
# Kernel#puts is defined in mruby-print mrbgem. '15.3.1.3.39'
|
||||
|
||||
assert('Kernel#raise', '15.3.1.3.40') do
|
||||
e_list = []
|
||||
|
||||
|
||||
@@ -129,6 +129,21 @@ assert('Module#const_get', '15.2.2.4.23') do
|
||||
Test4ConstSet.const_get(:Const4Test4ConstSet) == 23
|
||||
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
|
||||
module Test4Include
|
||||
Const4Include = 42
|
||||
|
||||
+5
-5
@@ -32,7 +32,7 @@ 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')
|
||||
# 'String#=~', '15.2.10.5.5' will be tested in mrbgems.
|
||||
|
||||
assert('String#[]', '15.2.10.5.6') do
|
||||
# length of args is 1
|
||||
@@ -49,7 +49,7 @@ assert('String#[]', '15.2.10.5.6') do
|
||||
e1 = 'abc'[1, 2]
|
||||
|
||||
# args is RegExp
|
||||
# TODO SEGFAULT ATM
|
||||
# It will be tested in mrbgems.
|
||||
|
||||
# args is String
|
||||
a3 = 'abc'['bc']
|
||||
@@ -251,7 +251,7 @@ 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
|
||||
# 'String#match', '15.2.10.5.27' will be tested in mrbgems.
|
||||
|
||||
assert('String#replace', '15.2.10.5.28') do
|
||||
a = ''
|
||||
@@ -279,7 +279,7 @@ assert('String#rindex', '15.2.10.5.31') do
|
||||
'abcabc'.rindex('a', 1) == 0 and 'abcabc'.rindex('a', 4) == 3
|
||||
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
|
||||
'abc'.size == 3
|
||||
@@ -303,7 +303,7 @@ assert('String#slice', '15.2.10.5.34') do
|
||||
e11 = e1.slice(0)
|
||||
|
||||
# args is RegExp
|
||||
# TODO SEGFAULT ATM
|
||||
# It will be tested in mrbgems.
|
||||
|
||||
# args is String
|
||||
a3 = 'abc'.slice('bc')
|
||||
|
||||
Reference in New Issue
Block a user