-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 9.4.12.0
- 9.4.11.0
- 9.4.10.0
- 9.4.9.0
- 9.4.8.0
- 9.4.7.0
- 9.4.6.0
- 9.4.5.0
- 9.4.4.0
- 9.4.3.0
- 9.4.2.0
- 9.4.1.0
- 9.4.0.0
- 9.3.15.0
- 9.3.14.0
- 9.3.13.0
- 9.3.12.0
- 9.3.11.0
- 9.3.10.0
- 9.3.9.0
- 9.3.8.0
- 9.3.7.0
- 9.3.6.0
- 9.3.5.0
- 9.3.4.0
- 9.3.3.0
- 9.3.2.0
- 9.3.1.0
- 9.3.0.0
- 9.2.21.0
- 9.2.20.1
- 9.2.20.0
- 9.2.19.0
- 9.2.18.0
- 9.2.17.0
- 9.2.16.0
- 9.2.15.0
- 9.2.14.0
- 9.2.13.0
- 9.2.12.0
- 9.2.11.1
- 9.2.11.0
- 9.2.10.0
- 9.2.9.0
- 9.2.8.0
- 9.2.7.0
- 9.2.6.0
- 9.2.5.0
- 9.2.4.1
- 9.2.4.0
- 9.2.3.0
- 9.2.2.0
- 9.2.1.0
- 9.2.0.0
- 9.1.17.0
- 9.1.16.0
- 9.1.15.0
- 9.1.14.0
- 9.1.13.0
- 9.1.12.0
- 9.1.11.0
- 9.1.10.0
- 9.1.9.0
- 9.1.8.0
- 9.1.7.0
- 9.1.6.0
- 9.1.5.0
- 9.1.4.0
- 9.1.3.0
- 9.1.2.0
- 9.1.1.0
1 parent
c337fe2
commit cb15935
Showing
14 changed files
with
434 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (c) 2016 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 | ||
|
||
require_relative '../../../../ruby/spec_helper' | ||
|
||
describe "Truffle::Interop.boxed?" do | ||
|
||
it "returns false for empty strings" do | ||
Truffle::Interop.boxed?('').should be_false | ||
end | ||
|
||
it "returns true for strings with one byte" do | ||
Truffle::Interop.boxed?('1').should be_true | ||
end | ||
|
||
it "returns false for strings with two bytes" do | ||
Truffle::Interop.boxed?('12').should be_false | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# Copyright (c) 2016 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 | ||
|
||
require_relative '../../../../ruby/spec_helper' | ||
|
||
describe "Truffle::Interop.executable?" do | ||
|
||
def test_method | ||
end | ||
|
||
it "returns true for methods" do | ||
Truffle::Interop.executable?(method(:test_method)).should be_true | ||
end | ||
|
||
it "returns true for procs" do | ||
Truffle::Interop.executable?(proc { }).should be_true | ||
end | ||
|
||
it "returns true for lambdas" do | ||
Truffle::Interop.executable?(lambda { }).should be_true | ||
end | ||
|
||
it "returns false for nil" do | ||
Truffle::Interop.executable?(nil).should be_false | ||
end | ||
|
||
it "returns false for strings" do | ||
Truffle::Interop.executable?('hello').should be_false | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (c) 2016 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 | ||
|
||
require_relative '../../../../ruby/spec_helper' | ||
|
||
describe "Truffle::Interop.execute" do | ||
|
||
def add(a, b) | ||
a + b | ||
end | ||
|
||
it "calls methods" do | ||
Truffle::Interop.execute(method(:add), 14, 2).should == 16 | ||
end | ||
|
||
it "calls procs" do | ||
Truffle::Interop.execute(proc { |a, b| a + b }, 14, 2).should == 16 | ||
end | ||
|
||
it "calls lambdas" do | ||
Truffle::Interop.execute(lambda { |a, b| a + b }, 14, 2).should == 16 | ||
end | ||
|
||
it "doesn't call nil" do | ||
lambda { Truffle::Interop.execute(nil) }.should raise_error(RubyTruffleError) | ||
end | ||
|
||
it "doesn't call strings" do | ||
lambda { Truffle::Interop.execute('hello') }.should raise_error(RubyTruffleError) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) 2016 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 | ||
|
||
require_relative '../../../../ruby/spec_helper' | ||
|
||
describe "Truffle::Interop.invoke" do | ||
|
||
class InvokeTestClass | ||
|
||
def add(a, b) | ||
a + b | ||
end | ||
|
||
end | ||
|
||
it "invokes methods using symbols" do | ||
Truffle::Interop.invoke(InvokeTestClass.new, :add, 14, 2).should == 16 | ||
end | ||
|
||
it "invokes methods using strings" do | ||
Truffle::Interop.invoke(InvokeTestClass.new, 'add', 14, 2).should == 16 | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) 2016 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 | ||
|
||
require_relative '../../../../ruby/spec_helper' | ||
|
||
describe "Truffle::Interop.null?" do | ||
|
||
it "returns true for nil" do | ||
Truffle::Interop.null?(nil).should be_true | ||
end | ||
|
||
it "returns false for strings" do | ||
Truffle::Interop.null?('').should be_false | ||
end | ||
|
||
it "returns false for zero" do | ||
Truffle::Interop.null?(0).should be_false | ||
end | ||
|
||
it "returns false for false" do | ||
Truffle::Interop.null?(false).should be_false | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Copyright (c) 2016 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 | ||
|
||
require_relative '../../../../ruby/spec_helper' | ||
|
||
describe "Truffle::Interop.read" do | ||
|
||
class ReadInstanceVariable | ||
|
||
def initialize | ||
@foo = 14 | ||
end | ||
|
||
end | ||
|
||
class HasMethod | ||
|
||
def foo | ||
14 | ||
end | ||
|
||
end | ||
|
||
class HasIndex | ||
|
||
def [](n) | ||
14 | ||
end | ||
|
||
end | ||
|
||
it "reads a byte from a string" do | ||
Truffle::Interop.read('123', 1).should == '2'.ord | ||
end | ||
|
||
describe "reads an instance variable if given an @name" do | ||
it "as a symbol" do | ||
Truffle::Interop.read(ReadInstanceVariable.new, :@foo).should == 14 | ||
end | ||
|
||
it "as a string" do | ||
Truffle::Interop.read(ReadInstanceVariable.new, '@foo').should == 14 | ||
end | ||
end | ||
|
||
describe "calls #[] if there isn't a method with the same name" do | ||
it "as a symbol" do | ||
Truffle::Interop.read(HasIndex.new, :foo).should == 14 | ||
end | ||
|
||
it "as a string" do | ||
Truffle::Interop.read(HasIndex.new, 'foo').should == 14 | ||
end | ||
end | ||
|
||
describe "calls a method if there is a method with the same name" do | ||
it "as a symbol" do | ||
Truffle::Interop.read(HasMethod.new, :foo).should == 14 | ||
end | ||
|
||
it "as a string" do | ||
Truffle::Interop.read(HasMethod.new, 'foo').should == 14 | ||
end | ||
end | ||
|
||
it "can be used to index an array" do | ||
Truffle::Interop.read([1, 2, 3], 1).should == 2 | ||
end | ||
|
||
it "can be used to index a hash" do | ||
Truffle::Interop.read({1 => 2, 3 => 4, 5 => 6}, 3).should == 4 | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Copyright (c) 2016 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 | ||
|
||
require_relative '../../../../ruby/spec_helper' | ||
|
||
describe "Truffle::Interop.size" do | ||
|
||
class InteropSizeClass | ||
|
||
def size | ||
14 | ||
end | ||
|
||
end | ||
|
||
it "returns the size of an array" do | ||
Truffle::Interop.size([1, 2, 3]).should == 3 | ||
end | ||
|
||
it "returns the size of an array" do | ||
Truffle::Interop.size({a: 1, b: 2, c: 3}).should == 3 | ||
end | ||
|
||
it "returns the size of an string" do | ||
Truffle::Interop.size('123').should == 3 | ||
end | ||
|
||
it "returns the size of any object with a size method" do | ||
Truffle::Interop.size(InteropSizeClass.new).should == 14 | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) 2016 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 | ||
|
||
require_relative '../../../../ruby/spec_helper' | ||
|
||
describe "Truffle::Interop.size?" do | ||
|
||
it "returns true for arrays" do | ||
Truffle::Interop.size?([]).should be_true | ||
end | ||
|
||
it "returns true for hashes" do | ||
Truffle::Interop.size?({}).should be_true | ||
end | ||
|
||
it "returns true for strings" do | ||
Truffle::Interop.size?('').should be_true | ||
end | ||
|
||
it "returns false for nil" do | ||
Truffle::Interop.size?(nil).should be_false | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Copyright (c) 2016 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 | ||
|
||
require_relative '../../../../ruby/spec_helper' | ||
|
||
describe "Truffle::Interop.unbox" do | ||
|
||
it "doesn't work on empty strings" do | ||
lambda { Truffle::Interop.unbox('') }.should raise_error(RubyTruffleError) | ||
end | ||
|
||
it "returns the first byte on strings with one byte" do | ||
Truffle::Interop.unbox('1').should == '1'.ord | ||
end | ||
|
||
it "returns the first byte on strings with two bytes" do | ||
Truffle::Interop.unbox('1').should == '1'.ord | ||
end | ||
|
||
it "returns nil for nil" do | ||
Truffle::Interop.unbox(nil).should be_nil | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Copyright (c) 2016 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 | ||
|
||
require_relative '../../../../ruby/spec_helper' | ||
|
||
describe "Truffle::Interop.write" do | ||
|
||
class HasMethod | ||
|
||
def foo=(value) | ||
@called = true | ||
end | ||
|
||
def called? | ||
@called | ||
end | ||
|
||
end | ||
|
||
class HasIndexSet | ||
|
||
def []=(n, value) | ||
@called = true | ||
end | ||
|
||
def called? | ||
@called | ||
end | ||
|
||
end | ||
|
||
describe "writes an instance variable if given an @name" do | ||
it "as a symbol" do | ||
object = Object.new | ||
Truffle::Interop.write ReadInstanceVariable.new, :@foo, 14 | ||
object.instance_variable_get('foo').should == 14 | ||
end | ||
|
||
it "as a string" do | ||
object = Object.new | ||
Truffle::Interop.write ReadInstanceVariable.new, '@foo', 14 | ||
object.instance_variable_get('foo').should == 14 | ||
end | ||
end | ||
|
||
describe "calls #[]= if there isn't a method with the same name" do | ||
it "as a symbol" do | ||
object = HasIndexSet.new | ||
Truffle::Interop.write object, :foo, 14 | ||
object.called?.should be_true | ||
end | ||
|
||
it "as a string" do | ||
object = HasIndexSet.new | ||
Truffle::Interop.write object, 'foo', 14 | ||
object.called?.should be_true | ||
end | ||
end | ||
|
||
describe "calls a method if there is a method with the same name plus =" do | ||
it "as a symbol" do | ||
object = HasMethod.new | ||
Truffle::Interop.write object, :foo, 14 | ||
object.called?.should be_true | ||
end | ||
|
||
it "as a string" do | ||
object = HasMethod.new | ||
Truffle::Interop.write object, 'foo', 14 | ||
object.called?.should be_true | ||
end | ||
end | ||
|
||
it "can be used to assign an array" do | ||
array = [1, 2, 3] | ||
Truffle::Interop.write array, 1, 14 | ||
array[1].should == 14 | ||
end | ||
|
||
it "can be used to assign a hash" do | ||
hash = {1 => 2, 3 => 4, 5 => 6} | ||
Truffle::Interop.write hash, 3, 14 | ||
hash[3].should == 14 | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:Truffle::Interop.null? returns false for zero | ||
fails:Truffle::Interop.null? returns false for false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
fails:Truffle::Interop.read can be used to index an array | ||
fails:Truffle::Interop.read can be used to index a hash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
fails:Truffle::Interop.size? returns true for arrays | ||
fails:Truffle::Interop.size? returns true for hashes | ||
fails:Truffle::Interop.size? returns true for strings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
fails:Truffle::Interop.write can be used to assign an array | ||
fails:Truffle::Interop.write can be used to assign a hash | ||
fails:Truffle::Interop.write writes an instance variable if given an @name as a symbol | ||
fails:Truffle::Interop.write writes an instance variable if given an @name as a string | ||
fails:Truffle::Interop.write calls #[]= if there isn't a method with the same name as a symbol | ||
fails:Truffle::Interop.write calls #[]= if there isn't a method with the same name as a string |
cb15935
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eregon @jtulach @grimmerm I wrote specs for our interop, and lots of them fail, such as the array ones, so that's why your interop tests aren't working