Skip to content

Commit

Permalink
Showing 2 changed files with 71 additions and 38 deletions.
40 changes: 2 additions & 38 deletions truffle/src/test/java/org/jruby/truffle/tck/RubyTckTest.java
Original file line number Diff line number Diff line change
@@ -31,50 +31,14 @@ public void checkVM() {

@Override
protected PolyglotEngine prepareVM() throws Exception {
final Source source = Source.fromText(
"def sum(a, b)\n"
+ " a + b\n"
+ "end\n"
+ "def fourty_two\n"
+ " 42\n"
+ "end\n"
+ "def ret_nil\n"
+ " nil\n"
+ "end\n"
+ "$invocations = 0\n"
+ "def count_invocations\n"
+ " $invocations += 1\n"
+ "end\n"
+ "def apply_numbers(f)\n"
+ " Truffle::Interop.execute(f, 18, 32) + 10\n"
+ "end\n"
+ "def compound_object\n"
+ " obj = Object.new\n"
+ " def obj.fourtyTwo; 42; end\n"
+ " def obj.plus(a, b); a + b; end\n"
+ " def obj.returnsNull; nil; end\n"
+ " def obj.returnsThis; self; end\n"
+ " obj\n"
+ "end\n"
+ "def identity(value)\n"
+ " value\n"
+ "end\n"
+ "Truffle::Interop.export(\"sum_ints\", method(:sum))\n"
+ "Truffle::Interop.export(\"fourty_two\", method(:fourty_two))\n"
+ "Truffle::Interop.export(\"ret_nil\", method(:ret_nil))\n"
+ "Truffle::Interop.export(\"count_invocations\", method(:count_invocations))\n"
+ "Truffle::Interop.export(\"apply_numbers\", method(:apply_numbers))\n"
+ "Truffle::Interop.export(\"compound_object\", method(:compound_object))\n"
+ "Truffle::Interop.export(\"identity\", method(:identity))\n",
"test").withMimeType(mimeType());
PolyglotEngine engine = PolyglotEngine.newBuilder().build();
engine.eval(source);
engine.eval(Source.fromFileName("src/test/ruby/tck.rb"));
return engine;
}

@Override
protected String plusInt() {
return "sum_ints";
return "plus_int";
}

@Override
69 changes: 69 additions & 0 deletions truffle/src/test/ruby/tck.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. This
# code is released under a tri EPL/GPL/LGPL license. You can use it,
# redistribute it and/or modify it under the terms of the:
#
# Eclipse Public License version 1.0
# GNU General Public License version 2
# GNU Lesser General Public License version 2.1

def plus_int(a, b)
a + b
end

Truffle::Interop.export_method(:plus_int)

def fourty_two
42
end

Truffle::Interop.export_method(:fourty_two)

def ret_nil
nil
end

Truffle::Interop.export_method(:ret_nil)

$invocations = 0

def count_invocations
$invocations += 1
end

Truffle::Interop.export_method(:count_invocations)

def apply_numbers(f)
Truffle::Interop.execute(f, 18, 32) + 10
end

Truffle::Interop.export_method(:apply_numbers)

def compound_object
obj = Object.new

def obj.fourtyTwo
42
end

def obj.plus(a, b)
a + b
end

def obj.returnsNull
nil
end

def obj.returnsThis
self
end

obj
end

Truffle::Interop.export_method(:compound_object)

def identity(value)
value
end

Truffle::Interop.export_method(:identity)

1 comment on commit f33e0a4

@chrisseaton
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For your information @jtulach

Please sign in to comment.