Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mruby
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
mruby
Commits
0719f523
Commit
0719f523
authored
Jun 03, 2012
by
Yukihiro "Matz" Matsumoto
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #240 from bovi/superclass-improvement
Class#superclass improvement
parents
7009a1d8
0c2d7402
Changes
26
Hide whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
127 additions
and
6 deletions
+127
-6
src/class.c
src/class.c
+9
-3
test/t/argumenterror.rb
test/t/argumenterror.rb
+5
-0
test/t/array.rb
test/t/array.rb
+4
-0
test/t/basicobject.rb
test/t/basicobject.rb
+11
-0
test/t/class.rb
test/t/class.rb
+7
-3
test/t/exception.rb
test/t/exception.rb
+4
-0
test/t/false.rb
test/t/false.rb
+4
-0
test/t/float.rb
test/t/float.rb
+4
-0
test/t/hash.rb
test/t/hash.rb
+4
-0
test/t/indexerror.rb
test/t/indexerror.rb
+5
-0
test/t/integer.rb
test/t/integer.rb
+4
-0
test/t/module.rb
test/t/module.rb
+4
-0
test/t/nameerror.rb
test/t/nameerror.rb
+4
-0
test/t/nomethoderror.rb
test/t/nomethoderror.rb
+5
-0
test/t/numeric.rb
test/t/numeric.rb
+4
-0
test/t/object.rb
test/t/object.rb
+5
-0
test/t/proc.rb
test/t/proc.rb
+4
-0
test/t/range.rb
test/t/range.rb
+4
-0
test/t/rangeerror.rb
test/t/rangeerror.rb
+5
-0
test/t/standarderror.rb
test/t/standarderror.rb
+5
-0
test/t/string.rb
test/t/string.rb
+4
-0
test/t/struct.rb
test/t/struct.rb
+5
-0
test/t/symbol.rb
test/t/symbol.rb
+4
-0
test/t/time.rb
test/t/time.rb
+4
-0
test/t/true.rb
test/t/true.rb
+4
-0
test/t/typeerror.rb
test/t/typeerror.rb
+5
-0
No files found.
src/class.c
View file @
0719f523
...
@@ -822,10 +822,16 @@ mrb_class_new_class(mrb_state *mrb, mrb_value cv)
...
@@ -822,10 +822,16 @@ mrb_class_new_class(mrb_state *mrb, mrb_value cv)
mrb_value
mrb_value
mrb_class_superclass
(
mrb_state
*
mrb
,
mrb_value
klass
)
mrb_class_superclass
(
mrb_state
*
mrb
,
mrb_value
klass
)
{
{
struct
RClass
*
c
,
*
s
;
struct
RClass
*
c
;
mrb_value
superclass
;
c
=
mrb_class_ptr
(
klass
);
c
=
mrb_class_ptr
(
klass
);
s
=
mrb_class_real
(
c
->
super
);
if
(
c
->
super
)
return
mrb_obj_value
(
s
);
superclass
=
mrb_obj_value
(
mrb_class_real
(
c
->
super
));
else
superclass
=
mrb_nil_value
();
return
superclass
;
}
}
static
mrb_value
static
mrb_value
...
...
test/t/argumenterror.rb
View file @
0719f523
...
@@ -13,3 +13,8 @@ assert('ArgumentError', '15.2.24') do
...
@@ -13,3 +13,8 @@ assert('ArgumentError', '15.2.24') do
ArgumentError
.
class
==
Class
and
e2
.
class
==
ArgumentError
ArgumentError
.
class
==
Class
and
e2
.
class
==
ArgumentError
end
end
assert
(
'ArgumentError superclass'
,
'15.2.24.2'
)
do
ArgumentError
.
superclass
==
StandardError
end
test/t/array.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('Array', '15.2.12') do
...
@@ -5,6 +5,10 @@ assert('Array', '15.2.12') do
Array
.
class
==
Class
Array
.
class
==
Class
end
end
assert
(
'Array superclass'
,
'15.2.12.2'
)
do
Array
.
superclass
==
Object
end
assert
(
'Array.[]'
,
'15.2.12.4.1'
)
do
assert
(
'Array.[]'
,
'15.2.12.4.1'
)
do
Array
.
[
](
1
,
2
,
3
)
==
[
1
,
2
,
3
]
Array
.
[
](
1
,
2
,
3
)
==
[
1
,
2
,
3
]
end
end
...
...
test/t/basicobject.rb
0 → 100644
View file @
0719f523
##
# BasicObject
assert
(
'BasicObject'
)
do
BasicObject
.
class
==
Class
end
assert
(
'BasicObject superclass'
)
do
BasicObject
.
superclass
==
nil
end
test/t/class.rb
View file @
0719f523
...
@@ -5,9 +5,8 @@ assert('Class', '15.2.3') do
...
@@ -5,9 +5,8 @@ assert('Class', '15.2.3') do
Class
.
class
==
Class
Class
.
class
==
Class
end
end
assert
(
'Class#superclass'
,
'15.2.3.3.4'
)
do
assert
(
'Class superclass'
,
'15.2.3.2'
)
do
class
SubClass
<
String
;
end
Class
.
superclass
==
Module
SubClass
.
superclass
==
String
end
end
assert
(
'Class#new'
,
'15.2.3.3.3'
)
do
assert
(
'Class#new'
,
'15.2.3.3.3'
)
do
...
@@ -40,6 +39,11 @@ assert('Class#new', '15.2.3.3.3') do
...
@@ -40,6 +39,11 @@ assert('Class#new', '15.2.3.3.3') do
# with block doesn't work yet
# with block doesn't work yet
end
end
assert
(
'Class#superclass'
,
'15.2.3.3.4'
)
do
class
SubClass
<
String
;
end
SubClass
.
superclass
==
String
end
# Not ISO specified
# Not ISO specified
assert
(
'Class 1'
)
do
assert
(
'Class 1'
)
do
...
...
test/t/exception.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('Exception', '15.2.22') do
...
@@ -5,6 +5,10 @@ assert('Exception', '15.2.22') do
Exception
.
class
==
Class
Exception
.
class
==
Class
end
end
assert
(
'Exception superclass'
,
'15.2.22.2'
)
do
Exception
.
superclass
==
Object
end
assert
(
'Exception.exception'
,
'15.2.22.4.1'
)
do
assert
(
'Exception.exception'
,
'15.2.22.4.1'
)
do
e
=
Exception
.
exception
(
'a'
)
e
=
Exception
.
exception
(
'a'
)
...
...
test/t/false.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('FalseClass', '15.2.6') do
...
@@ -5,6 +5,10 @@ assert('FalseClass', '15.2.6') do
FalseClass
.
class
==
Class
FalseClass
.
class
==
Class
end
end
assert
(
'FalseClass superclass'
,
'15.2.6.2'
)
do
FalseClass
.
superclass
==
Object
end
assert
(
'FalseClass false'
,
'15.2.6.1'
)
do
assert
(
'FalseClass false'
,
'15.2.6.1'
)
do
not
false
not
false
end
end
...
...
test/t/float.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('Float', '15.2.9') do
...
@@ -5,6 +5,10 @@ assert('Float', '15.2.9') do
Float
.
class
==
Class
Float
.
class
==
Class
end
end
assert
(
'Float superclass'
,
'15.2.9.2'
)
do
Float
.
superclass
==
Numeric
end
assert
(
'Float#+'
,
'15.2.9.3.1'
)
do
assert
(
'Float#+'
,
'15.2.9.3.1'
)
do
a
=
3.123456788
+
0.000000001
a
=
3.123456788
+
0.000000001
b
=
3.123456789
+
1
b
=
3.123456789
+
1
...
...
test/t/hash.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('Hash', '15.2.13') do
...
@@ -5,6 +5,10 @@ assert('Hash', '15.2.13') do
Hash
.
class
==
Class
Hash
.
class
==
Class
end
end
assert
(
'Hash superclass'
,
'15.2.13.2'
)
do
Hash
.
superclass
==
Object
end
assert
(
'Hash#=='
,
'15.2.13.4.1'
)
do
assert
(
'Hash#=='
,
'15.2.13.4.1'
)
do
({
'abc'
=>
'abc'
}
==
{
'abc'
=>
'abc'
})
and
({
'abc'
=>
'abc'
}
==
{
'abc'
=>
'abc'
})
and
not
({
'abc'
=>
'abc'
}
==
{
'cba'
=>
'cba'
})
not
({
'abc'
=>
'abc'
}
==
{
'cba'
=>
'cba'
})
...
...
test/t/indexerror.rb
View file @
0719f523
...
@@ -4,3 +4,8 @@
...
@@ -4,3 +4,8 @@
assert
(
'IndexError'
,
'15.2.33'
)
do
assert
(
'IndexError'
,
'15.2.33'
)
do
IndexError
.
class
==
Class
IndexError
.
class
==
Class
end
end
assert
(
'IndexError superclass'
,
'15.2.33.2'
)
do
IndexError
.
superclass
==
StandardError
end
test/t/integer.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('Integer', '15.2.8') do
...
@@ -5,6 +5,10 @@ assert('Integer', '15.2.8') do
Integer
.
class
==
Class
Integer
.
class
==
Class
end
end
assert
(
'Integer superclass'
,
'15.2.8.2'
)
do
Integer
.
superclass
==
Numeric
end
assert
(
'Integer#+'
,
'15.2.8.3.1'
)
do
assert
(
'Integer#+'
,
'15.2.8.3.1'
)
do
a
=
1
+
1
a
=
1
+
1
b
=
1
+
1.0
b
=
1
+
1.0
...
...
test/t/module.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('Module', '15.2.2') do
...
@@ -5,6 +5,10 @@ assert('Module', '15.2.2') do
Module
.
class
==
Class
Module
.
class
==
Class
end
end
assert
(
'Module superclass'
,
'15.2.2.2'
)
do
Module
.
superclass
==
Object
end
assert
(
'Module#const_defined?'
,
'15.2.2.4.20'
)
do
assert
(
'Module#const_defined?'
,
'15.2.2.4.20'
)
do
module
Test4ConstDefined
module
Test4ConstDefined
Const4Test4ConstDefined
=
true
Const4Test4ConstDefined
=
true
...
...
test/t/nameerror.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('NameError', '15.2.31') do
...
@@ -5,6 +5,10 @@ assert('NameError', '15.2.31') do
NameError
.
class
==
Class
NameError
.
class
==
Class
end
end
assert
(
'NameError superclass'
,
'15.2.31.2'
)
do
NameError
.
superclass
==
StandardError
end
# TODO 15.2.31.2.1 NameError#name
# TODO 15.2.31.2.1 NameError#name
assert
(
'NameError#initialize'
,
'15.2.31.2.2'
)
do
assert
(
'NameError#initialize'
,
'15.2.31.2.2'
)
do
...
...
test/t/nomethoderror.rb
View file @
0719f523
...
@@ -11,3 +11,8 @@ assert('NoMethodError', '15.2.32') do
...
@@ -11,3 +11,8 @@ assert('NoMethodError', '15.2.32') do
NoMethodError
.
class
==
Class
and
e2
.
class
==
NoMethodError
NoMethodError
.
class
==
Class
and
e2
.
class
==
NoMethodError
end
end
assert
(
'NoMethodError superclass'
,
'15.2.32.2'
)
do
NoMethodError
.
superclass
==
NameError
end
test/t/numeric.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('Numeric', '15.2.7') do
...
@@ -5,6 +5,10 @@ assert('Numeric', '15.2.7') do
Numeric
.
class
==
Class
Numeric
.
class
==
Class
end
end
assert
(
'Numeric superclass'
,
'15.2.7.2'
)
do
Numeric
.
superclass
==
Object
end
assert
(
'Numeric#+@'
,
'15.2.7.4.1'
)
do
assert
(
'Numeric#+@'
,
'15.2.7.4.1'
)
do
+
1
==
+
1
+
1
==
+
1
end
end
...
...
test/t/object.rb
View file @
0719f523
...
@@ -4,3 +4,8 @@
...
@@ -4,3 +4,8 @@
assert
(
'Object'
,
'15.2.1'
)
do
assert
(
'Object'
,
'15.2.1'
)
do
Object
.
class
==
Class
Object
.
class
==
Class
end
end
assert
(
'Object superclass'
,
'15.2.1.2'
)
do
Object
.
superclass
==
BasicObject
end
test/t/proc.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('Proc', '15.2.17') do
...
@@ -5,6 +5,10 @@ assert('Proc', '15.2.17') do
Proc
.
class
==
Class
Proc
.
class
==
Class
end
end
assert
(
'Proc superclass'
,
'15.2.17.2'
)
do
Proc
.
superclass
==
Object
end
assert
(
'Proc.new'
,
'15.2.17.3.1'
)
do
assert
(
'Proc.new'
,
'15.2.17.3.1'
)
do
a
=
nil
a
=
nil
...
...
test/t/range.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('Range', '15.2.14') do
...
@@ -5,6 +5,10 @@ assert('Range', '15.2.14') do
Range
.
class
==
Class
Range
.
class
==
Class
end
end
assert
(
'Range superclass'
,
'15.2.14.2'
)
do
Range
.
superclass
==
Object
end
assert
(
'Range#=='
,
'15.2.14.4.1'
)
do
assert
(
'Range#=='
,
'15.2.14.4.1'
)
do
(
1
..
10
)
==
(
1
..
10
)
and
not
(
1
..
10
)
==
(
1
..
100
)
(
1
..
10
)
==
(
1
..
10
)
and
not
(
1
..
10
)
==
(
1
..
100
)
end
end
...
...
test/t/rangeerror.rb
View file @
0719f523
...
@@ -4,3 +4,8 @@
...
@@ -4,3 +4,8 @@
assert
(
'RangeError'
,
'15.2.26'
)
do
assert
(
'RangeError'
,
'15.2.26'
)
do
RangeError
.
class
==
Class
RangeError
.
class
==
Class
end
end
assert
(
'RangeError superclass'
,
'15.2.26.2'
)
do
RangeError
.
superclass
==
StandardError
end
test/t/standarderror.rb
View file @
0719f523
...
@@ -4,3 +4,8 @@
...
@@ -4,3 +4,8 @@
assert
(
'StandardError'
,
'15.2.23'
)
do
assert
(
'StandardError'
,
'15.2.23'
)
do
StandardError
.
class
==
Class
StandardError
.
class
==
Class
end
end
assert
(
'StandardError superclass'
,
'15.2.23.2'
)
do
StandardError
.
superclass
==
Exception
end
test/t/string.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('String', '15.2.10') do
...
@@ -5,6 +5,10 @@ assert('String', '15.2.10') do
String
.
class
==
Class
String
.
class
==
Class
end
end
assert
(
'String superclass'
,
'15.2.10.2'
)
do
String
.
superclass
==
Object
end
assert
(
'String#*'
,
'15.2.10.5.1'
)
do
assert
(
'String#*'
,
'15.2.10.5.1'
)
do
'a'
*
5
==
'aaaaa'
'a'
*
5
==
'aaaaa'
end
end
...
...
test/t/struct.rb
View file @
0719f523
...
@@ -4,3 +4,8 @@
...
@@ -4,3 +4,8 @@
assert
(
'Struct'
,
'15.2.18'
)
do
assert
(
'Struct'
,
'15.2.18'
)
do
Struct
.
class
==
Class
Struct
.
class
==
Class
end
end
assert
(
'Struct superclass'
,
'15.2.18.2'
)
do
Struct
.
superclass
==
Object
end
test/t/symbol.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('Symbol', '15.2.11') do
...
@@ -5,6 +5,10 @@ assert('Symbol', '15.2.11') do
Symbol
.
class
==
Class
Symbol
.
class
==
Class
end
end
assert
(
'Symbol superclass'
,
'15.2.11.2'
)
do
Symbol
.
superclass
==
Object
end
assert
(
'Symbol#==='
,
'15.2.11.3.1'
)
do
assert
(
'Symbol#==='
,
'15.2.11.3.1'
)
do
:abc
===
:abc
and
not
:abc
===
:cba
:abc
===
:abc
and
not
:abc
===
:cba
end
end
...
...
test/t/time.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('Time', '15.2.19') do
...
@@ -5,6 +5,10 @@ assert('Time', '15.2.19') do
Time
.
class
==
Class
Time
.
class
==
Class
end
end
assert
(
'Time superclass'
,
'15.2.19.2'
)
do
Time
.
superclass
==
Object
end
assert
(
'Time.at'
,
'15.2.19.6.1'
)
do
assert
(
'Time.at'
,
'15.2.19.6.1'
)
do
Time
.
at
(
1300000000.0
)
Time
.
at
(
1300000000.0
)
end
end
...
...
test/t/true.rb
View file @
0719f523
...
@@ -5,6 +5,10 @@ assert('TrueClass', '15.2.5') do
...
@@ -5,6 +5,10 @@ assert('TrueClass', '15.2.5') do
TrueClass
.
class
==
Class
TrueClass
.
class
==
Class
end
end
assert
(
'TrueClass superclass'
,
'15.2.5.2'
)
do
TrueClass
.
superclass
==
Object
end
assert
(
'TrueClass true'
,
'15.2.5.1'
)
do
assert
(
'TrueClass true'
,
'15.2.5.1'
)
do
true
true
end
end
...
...
test/t/typeerror.rb
View file @
0719f523
...
@@ -4,3 +4,8 @@
...
@@ -4,3 +4,8 @@
assert
(
'TypeError'
,
'15.2.29'
)
do
assert
(
'TypeError'
,
'15.2.29'
)
do
TypeError
.
class
==
Class
TypeError
.
class
==
Class
end
end
assert
(
'TypeError superclass'
,
'15.2.29.2'
)
do
TypeError
.
superclass
==
StandardError
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment