Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add possibility to inherit classes

  • Loading branch information...
commit 200959930cd48b31bc6c3087265562a94957c5f4 1 parent 4c27546
@txus authored
View
5 lib/noscript/runtime.rb
@@ -116,8 +116,9 @@ def noscript_def(name, &block)
class Class
noscript_alias [:new]
- noscript_def 'create' do |implementation|
- Class.new(&implementation)
+ noscript_def 'create' do |*args|
+ implementation = args.pop
+ Class.new(*args, &implementation)
end
end
View
2  lib/noscript/signature.rb
@@ -1,3 +1,3 @@
# This file is generated by `rake signature`. The signature
# is used to ensure that only current compiled files are loaded.
-Noscript::Signature = Rubinius::Signature ^ 1341661358288879324
+Noscript::Signature = Rubinius::Signature ^ 13667765703280290701
View
18 test/interop_test.rb
@@ -25,7 +25,7 @@ def test_assign_toplevel_namespace
def test_define_ruby_method
compile(<<-CODE)
Ruby.Array.def('sum', ->
- @ruby('reduce', '+'.ruby('to_sym'))
+ @ruby('reduce', '+')
end)
CODE
@@ -84,6 +84,22 @@ def test_create_ruby_class
assert_equal 42, foo.answer
end
+ def test_create_ruby_class_inheriting
+ kls = compile(<<-CODE)
+ Ruby.Class.create(Ruby.Array, ->
+ @def('answer', ->
+ 42
+ end)
+ end)
+ CODE
+
+ foo = kls.new
+
+ assert_respond_to foo, :answer
+ assert_kind_of Array, foo
+ assert_equal 42, foo.answer
+ end
+
def test_call_noscript_from_ruby
john = compile(<<-CODE)
Object.clone({
Please sign in to comment.
Something went wrong with that request. Please try again.