Permalink
Browse files

Class#create interop API

  • Loading branch information...
1 parent 257b3be commit 38139520e8ff3e9dbf51eef27d5bb485ec1a27e9 @txus committed Jan 27, 2012
Showing with 18 additions and 0 deletions.
  1. +3 −0 lib/noscript/runtime.rb
  2. +15 −0 test/interop_test.rb
View
@@ -102,6 +102,9 @@ def noscript_def(name, &block)
class Class
noscript_alias [:new]
+ noscript_def 'create' do |implementation|
+ Class.new(&implementation)
+ end
end
class Module
View
@@ -63,4 +63,19 @@ def test_create_ruby_module
assert_respond_to foo, :answer
assert_equal 42, foo.answer
end
+
+ def test_create_ruby_clas
+ kls = compile(<<-CODE)
+ Ruby.Class.create(->
+ @def('answer', ->
+ 42
+ end)
+ end)
+ CODE
+
+ foo = kls.new
+
+ assert_respond_to foo, :answer
+ assert_equal 42, foo.answer
+ end
end

0 comments on commit 3813952

Please sign in to comment.