Permalink
Browse files

Add possibility to inherit classes

  • Loading branch information...
1 parent 4c27546 commit 200959930cd48b31bc6c3087265562a94957c5f4 @txus committed Jan 27, 2012
Showing with 21 additions and 4 deletions.
  1. +3 −2 lib/noscript/runtime.rb
  2. +1 −1 lib/noscript/signature.rb
  3. +17 −1 test/interop_test.rb
View
@@ -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
@@ -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
@@ -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({

0 comments on commit 2009599

Please sign in to comment.