Skip to content

Commit

Permalink
Showing 45 changed files with 815 additions and 10 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ env:
- PHASE='-Ptruffle-specs-language'
- PHASE='-Ptruffle-specs-core'
- PHASE='-Ptruffle-specs-library'
- PHASE='-Ptruffle-specs-truffle'
- PHASE='-Ptruffle-mri-tests'

matrix:
14 changes: 11 additions & 3 deletions pom.rb
Original file line number Diff line number Diff line change
@@ -172,9 +172,17 @@
end

[
'rake', 'exec', 'truffle-specs-language', 'truffle-specs-core',
'truffle-specs-library', 'truffle-specs-language-report',
'truffle-specs-core-report', 'truffle-specs-library-report', 'truffle-test-pe', 'truffle-mri-tests'
'rake',
'exec',
'truffle-specs-language',
'truffle-specs-core',
'truffle-specs-library',
'truffle-specs-truffle',
'truffle-specs-language-report',
'truffle-specs-core-report',
'truffle-specs-library-report',
'truffle-test-pe',
'truffle-mri-tests'
].each do |name|
profile name do

9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -570,6 +570,15 @@
<module>test</module>
</modules>
</profile>
<profile>
<id>truffle-specs-truffle</id>
<build>
<defaultGoal>package</defaultGoal>
</build>
<modules>
<module>test</module>
</modules>
</profile>
<profile>
<id>truffle-specs-language-report</id>
<build>
80 changes: 80 additions & 0 deletions spec/truffle/specs/truffle/attachments/attach_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Attachments.attach" do

def fixture
x = 14
y = 15
y = 16
x
end

after :all do
[14, 15, 16].each do |line|
Truffle::Attachments.detach __FILE__, line
end
end

it "returns nil" do
Truffle::Attachments.attach(__FILE__, 14){}.should be_nil
end

it "installs a block to be run on a line" do
scratch = [false]
Truffle::Attachments.attach __FILE__, 14 do
scratch[0] = true
end
fixture.should == 14
scratch[0].should be_true
end

it "allows multiple blocks to be installed on the same line and runs them in an indeterminate order" do
scratch = []
Truffle::Attachments.attach __FILE__, 14 do
scratch << 1
end
Truffle::Attachments.attach __FILE__, 14 do
scratch << 2
end
fixture.should == 14
scratch.sort.should == [1, 2]
end

it "supplies a Binding to the block" do
Truffle::Attachments.attach __FILE__, 14 do |binding|
binding.should be_kind_of(Binding)
end
fixture.should == 14
end

it "allows read access to local variables in the block" do
Truffle::Attachments.attach __FILE__, 15 do |binding|
binding.local_variable_get(:x).should == 14
end
fixture.should == 14
end

it "allows write access to local variables in the block" do
Truffle::Attachments.attach __FILE__, 15 do |binding|
binding.local_variable_set(:x, 100)
end
fixture.should == 100
end

it "runs the block before running the line" do
Truffle::Attachments.attach __FILE__, 16 do |binding|
binding.local_variable_get(:x).should == 14
binding.local_variable_get(:y).should == 15
end
fixture.should == 14
end

end
54 changes: 54 additions & 0 deletions spec/truffle/specs/truffle/attachments/detach_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Attachments.attach" do

def fixture
x = 14
x
end

it "returns nil" do
Truffle::Attachments.detach(__FILE__, 14).should be_nil
end

it "removes a previous attachment" do
scratch = []

scratch[0] = false
Truffle::Attachments.attach __FILE__, 14 do
scratch[0] = true
end
fixture.should == 14
scratch[0].should be_true

scratch[0] = false
Truffle::Attachments.detach __FILE__, 14
fixture.should == 14
scratch[0].should be_false
end

it "removes multiple previous attachments" do
scratch = []
Truffle::Attachments.attach __FILE__, 14 do
scratch << 1
end
Truffle::Attachments.attach __FILE__, 14 do
scratch << 2
end
fixture.should == 14
scratch.sort.should == [1, 2]

Truffle::Attachments.detach __FILE__, 14
fixture.should == 14
scratch.sort.should == [1, 2]
end

end
33 changes: 33 additions & 0 deletions spec/truffle/specs/truffle/binding_of_caller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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

require_relative '../../../ruby/spec_helper'

describe "Truffle.binding_of_caller" do

it "returns a Binding" do
Truffle.binding_of_caller.should be_kind_of(Binding)
end

it "gives read access to local variables at the call site" do
x = 14
Truffle.binding_of_caller.local_variable_get(:x).should == 14
end

it "gives write access to local variables at the call site" do
x = 2
Truffle.binding_of_caller.local_variable_set(:x, 14)
x.should == 14
end

it "works through #send" do
x = 14
Truffle.send(:binding_of_caller).local_variable_get(:x).should == 14
end

end
7 changes: 7 additions & 0 deletions spec/truffle/specs/truffle/cext/fixtures/foo/ext/foo/add.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include <ruby.h>

#include "add.h"

VALUE add(VALUE self, VALUE a, VALUE b) {
return INT2NUM(NUM2INT(a) + NUM2INT(b));
}
1 change: 1 addition & 0 deletions spec/truffle/specs/truffle/cext/fixtures/foo/ext/foo/add.h
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VALUE add(VALUE self, VALUE a, VALUE b);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require 'mkmf'
$CFLAGS << ' -Wall'
create_makefile('foo/foo')
8 changes: 8 additions & 0 deletions spec/truffle/specs/truffle/cext/fixtures/foo/ext/foo/foo.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <ruby.h>

#include "add.h"

void Init_foo() {
VALUE Foo = rb_define_module("Foo");
rb_define_method(Foo, "add", add, 2);
}
27 changes: 27 additions & 0 deletions spec/truffle/specs/truffle/cext/inline_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::CExt.inline" do

if Truffle::CExt.supported?

it "needs to be reviewed for spec completeness"

else

it "raises a RuntimeError" do
lambda {
Truffle::CExt.inline %{ #include <unistd.h> }, %{ getpid(); }
}.should raise_error(RuntimeError)
end

end

end
27 changes: 27 additions & 0 deletions spec/truffle/specs/truffle/cext/load_extconf_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::CExt.load_extconf" do

if Truffle::CExt.supported?

it "needs to be reviewed for spec completeness"

else

it "raises a RuntimeError" do
lambda {
Truffle::CExt.load_extconf File.expand_path('fixtures/foo/ext/foo/extconf.rb', __FILE__)
}.should raise_error(RuntimeError)
end

end

end
31 changes: 31 additions & 0 deletions spec/truffle/specs/truffle/cext/load_files_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::CExt.load_files" do

if Truffle::CExt.supported?

it "needs to be reviewed for spec completeness"

else

it "raises a RuntimeError" do
files = [
File.expand_path('fixtures/foo/ext/foo/foo.c', __FILE__),
File.expand_path('fixtures/foo/ext/foo/add.c', __FILE__)
]
lambda {
Truffle::CExt.load_files ['Init_foo'], [], files
}.should raise_error(RuntimeError)
end

end

end
31 changes: 31 additions & 0 deletions spec/truffle/specs/truffle/cext/load_string_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::CExt.load_string" do

if Truffle::CExt.supported?

it "needs to be reviewed for spec completeness"

else

it "raises a RuntimeError" do
source = %{
void Init_foo() {
}
}
lambda {
Truffle::CExt.load_files ['Init_foo'], [], source
}.should raise_error(RuntimeError)
end

end

end
17 changes: 17 additions & 0 deletions spec/truffle/specs/truffle/cext/supported_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::CExt.supported?" do

it "returns a Boolean value" do
Truffle::CExt.supported?.should be_true_or_false
end

end
15 changes: 15 additions & 0 deletions spec/truffle/specs/truffle/debug/break_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Debug.break" do

it "needs to be reviewed for spec completeness"

end
15 changes: 15 additions & 0 deletions spec/truffle/specs/truffle/debug/clear_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Debug.clear" do

it "needs to be reviewed for spec completeness"

end
17 changes: 17 additions & 0 deletions spec/truffle/specs/truffle/graal_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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

require_relative '../../../ruby/spec_helper'

describe "Truffle.graal?" do

it "returns a Boolean value" do
Truffle.graal?.should be_true_or_false
end

end
23 changes: 23 additions & 0 deletions spec/truffle/specs/truffle/primitive/assert_constant_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Primitive.assert_constant" do

it "raises a RuntimeError when called dynamically" do
lambda{ Truffle::Primitive.send(:assert_constant, 14 + 2) }.should raise_error(RuntimeError)
end

unless Truffle.graal?
it "returns nil" do
Truffle::Primitive.assert_constant(14 + 2).should be_nil
end
end

end
23 changes: 23 additions & 0 deletions spec/truffle/specs/truffle/primitive/assert_not_compiled_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Primitive.assert_not_compiled" do

it "raises a RuntimeError when called dynamically" do
lambda{ Truffle::Primitive.send(:assert_not_compiled) }.should raise_error(RuntimeError)
end

unless Truffle.graal?
it "returns nil" do
Truffle::Primitive.assert_not_compiled.should be_nil
end
end

end
19 changes: 19 additions & 0 deletions spec/truffle/specs/truffle/primitive/coverage_result_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Primitive.coverage_result" do

it "returns nil" do
Truffle::Primitive.coverage_result.should be_nil
end

it "needs to be reviewed for spec completeness"

end
19 changes: 19 additions & 0 deletions spec/truffle/specs/truffle/primitive/coverage_start_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Primitive.coverage_start" do

it "returns nil" do
Truffle::Primitive.coverage_start.should be_nil
end

it "needs to be reviewed for spec completeness"

end
26 changes: 26 additions & 0 deletions spec/truffle/specs/truffle/primitive/gc_count_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Primitive.gc_count" do

it "returns an Integer" do
Truffle::Primitive.gc_count.should be_kind_of(Integer)
end

it "increases as collections are run" do
count_before = Truffle::Primitive.gc_count
escape = []
100_000.times do
escape << Time.now.to_s
end
Truffle::Primitive.gc_count.should > count_before
end

end
26 changes: 26 additions & 0 deletions spec/truffle/specs/truffle/primitive/gc_time_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Primitive.gc_time" do

it "returns an Integer" do
Truffle::Primitive.gc_time.should be_kind_of(Integer)
end

it "increases as collections are run" do
time_before = Truffle::Primitive.gc_time
escape = []
100_000.times do
escape << Time.now.to_s
end
Truffle::Primitive.gc_time.should > time_before
end

end
21 changes: 21 additions & 0 deletions spec/truffle/specs/truffle/primitive/home_directory_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Primitive.home_directory" do

it "returns a String" do
Truffle::Primitive.home_directory.should be_kind_of(String)
end

it "returns a path to a directory" do
Dir.exist?(Truffle::Primitive.home_directory).should be_true
end

end
17 changes: 17 additions & 0 deletions spec/truffle/specs/truffle/primitive/host_os_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Primitive.host_os" do

it "returns a String" do
Truffle::Primitive.host_os.should be_kind_of(String)
end

end
15 changes: 15 additions & 0 deletions spec/truffle/specs/truffle/primitive/simple_shell_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Primitive.simple_shell" do

it "needs to be reviewed for spec completeness"

end
15 changes: 15 additions & 0 deletions spec/truffle/specs/truffle/runtime/debug_print_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Runtime.debug_print" do

it "needs to be reviewed for spec completeness"

end
25 changes: 25 additions & 0 deletions spec/truffle/specs/truffle/runtime/dump_string_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Runtime.dump_string" do

it "returns a String" do
Truffle::Runtime.dump_string('foo').should be_kind_of(String)
end

it "returns a sequence of escaped bytes in lower case" do
Truffle::Runtime.dump_string('foo').should =~ /(\\x[0-9a-f][0-9a-f])+/
end

it "returns correct bytes for the given string" do
Truffle::Runtime.dump_string('foo').should == "\\x66\\x6f\\x6f"
end

end
41 changes: 41 additions & 0 deletions spec/truffle/specs/truffle/runtime/java_class_of_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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

require_relative '../../../../ruby/spec_helper'

describe "Truffle::Runtime.java_class_of" do

it "returns a String" do
Truffle::Runtime.java_class_of(14).should be_kind_of(String)
end

it "returns 'Boolean' for true" do
Truffle::Runtime.java_class_of(true).should == 'Boolean'
end

it "returns 'Boolean' for false" do
Truffle::Runtime.java_class_of(false).should == 'Boolean'
end

it "returns 'Integer' for a small Fixnum" do
Truffle::Runtime.java_class_of(14).should == 'Integer'
end

it "returns 'Long' for a large Fixnum" do
Truffle::Runtime.java_class_of(0xffffffffffff).should == 'Long'
end

it "returns 'Double' for a Float" do
Truffle::Runtime.java_class_of(3.14).should == 'Double'
end

it "returns 'RubyString' for a String" do
Truffle::Runtime.java_class_of('test').should == 'RubyString'
end

end
26 changes: 26 additions & 0 deletions spec/truffle/specs/truffle/source_of_caller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# 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

require_relative '../../../ruby/spec_helper'

describe "Truffle.source_of_caller" do

it "returns a String" do
Truffle.source_of_caller.should be_kind_of(String)
end

it "returns the name of the file at the call site" do
Truffle.source_of_caller.should == __FILE__
end

it "works through #send" do
x = 14
Truffle.send(:source_of_caller).should == __FILE__
end

end
17 changes: 17 additions & 0 deletions spec/truffle/specs/truffle/substrate_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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

require_relative '../../../ruby/spec_helper'

describe "Truffle.substrate?" do

it "returns a Boolean value" do
Truffle.graal?.should be_true_or_false
end

end
17 changes: 17 additions & 0 deletions spec/truffle/specs/truffle/version_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# 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

require_relative '../../../ruby/spec_helper'

describe "Truffle.version" do

it "returns a String" do
Truffle.version.should be_kind_of(String)
end

end
3 changes: 3 additions & 0 deletions spec/truffle/tags/truffle/attachments/attach_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:Truffle::Attachments.attach allows multiple blocks to be installed on the same line and runs them in the order they were attached
fails:Truffle::Attachments.attach allows write access to local variables in the block
fails:Truffle::Attachments.attach runs the block before running the line
2 changes: 2 additions & 0 deletions spec/truffle/tags/truffle/binding_of_caller_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Truffle.binding_of_caller gives read access to local variables at the call site
fails:Truffle.binding_of_caller gives write access to local variables at the call site
1 change: 1 addition & 0 deletions spec/truffle/tags/truffle/cext/load_extconf_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Truffle::CExt.load_extconf raises a RuntimeError
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Truffle::Primitive.coverage_result returns nil
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
fails:Truffle::Primitive.coverage_start returns nil
2 changes: 2 additions & 0 deletions spec/truffle/tags/truffle/source_of_caller_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
fails:Truffle.source_of_caller returns a String
fails:Truffle.source_of_caller returns the name of the file at the call site
7 changes: 6 additions & 1 deletion spec/truffle/truffle.mspec
Original file line number Diff line number Diff line change
@@ -147,10 +147,15 @@ class MSpecScript
"^spec/ruby/library/prime/each_spec.rb",
]

set :truffle, [
"spec/truffle/specs"
]

set :tags_patterns, [
[%r(^.*/language/), 'spec/truffle/tags/language/'],
[%r(^.*/core/), 'spec/truffle/tags/core/'],
[%r(^.*/library/), 'spec/truffle/tags/library/'],
[%r(^.*/truffle/), 'spec/truffle/tags/truffle/'],
[/_spec.rb$/, '_tags.txt']
]

@@ -164,6 +169,6 @@ class MSpecScript
MSpec.disable_feature :fork
MSpec.enable_feature :generator

set :files, get(:language) + get(:core) + get(:library)
set :files, get(:language) + get(:core) + get(:library) + get(:truffle)

end
11 changes: 11 additions & 0 deletions test/pom.rb
Original file line number Diff line number Diff line change
@@ -232,6 +232,17 @@ def truffle_spec_config(spec_type, generate_report)

end

profile 'truffle-specs-truffle' do

plugin :antrun do
execute_goals( 'run',
:id => 'rake',
:phase => 'test',
:configuration => [ xml( truffle_spec_config(:truffle, false) ) ] )
end

end

profile 'truffle-specs-language-report' do

plugin :antrun do
45 changes: 45 additions & 0 deletions test/pom.xml
Original file line number Diff line number Diff line change
@@ -792,6 +792,51 @@
</plugins>
</build>
</profile>
<profile>
<id>truffle-specs-truffle</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>rake</id>
<phase>test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<exec failonerror="true" dir="${jruby.home}" executable="${jruby.home}/bin/jruby">
<arg value="-X+T" />
<arg value="-Xparser.warn.useless_use_of=false" />
<arg value="-Xparser.warn.not_reached=false" />
<arg value="-Xparser.warn.grouped_expressions=false" />
<arg value="-Xparser.warn.shadowing_local=false" />
<arg value="-Xparser.warn.regex_condition=false" />
<arg value="-Xparser.warn.argument_prefix=false" />
<arg value="-Xparser.warn.ambiguous_argument=false" />
<arg value="-Xparser.warn.flags_ignored=false" />
<arg value="-J-ea" />
<arg value="-J-Xmx1G" />
<arg value="spec/mspec/bin/mspec" />
<arg value="run" />
<arg value="--config" />
<arg value="spec/truffle/truffle.mspec" />
<arg value="--excl-tag" />
<arg value="fails" />
<arg value="--format" />
<arg value="specdoc" />
<arg value=":truffle" />
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>truffle-specs-language-report</id>
<build>
Original file line number Diff line number Diff line change
@@ -83,7 +83,7 @@ public LocalVariableGetNode(RubyContext context, SourceSection sourceSection) {
public Object localVariableGetCached(RubyBinding binding, RubySymbol symbol,
@Cached("symbol") RubySymbol cachedSymbol,
@Cached("getFrameDescriptor(binding)") FrameDescriptor cachedFrameDescriptor,
@Cached("findFrameSlot(cachedFrameDescriptor, symbol)") FrameSlot cachedFrameSlot,
@Cached("findFrameSlot(binding, symbol)") FrameSlot cachedFrameSlot,
@Cached("createReadNode(cachedFrameSlot)") ReadAbstractFrameSlotNode readLocalVariableNode) {
if (cachedFrameSlot == null) {
CompilerDirectives.transferToInterpreter();
@@ -124,12 +124,30 @@ protected FrameDescriptor getFrameDescriptor(RubyBinding binding) {
return binding.getFrame().getFrameDescriptor();
}

protected FrameSlot findFrameSlot(FrameDescriptor frameDescriptor, RubySymbol symbol) {
return frameDescriptor.findFrameSlot(symbol.toString());
protected FrameSlot findFrameSlot(RubyBinding binding, RubySymbol symbol) {
final String symbolString = symbol.toString();

MaterializedFrame frame = binding.getFrame();

while (frame != null) {
final FrameSlot frameSlot = frame.getFrameDescriptor().findFrameSlot(symbolString);

if (frameSlot != null) {
return frameSlot;
}

frame = RubyArguments.getDeclarationFrame(frame.getArguments());
}

return null;
}

protected ReadAbstractFrameSlotNode createReadNode(FrameSlot frameSlot) {
return ReadAbstractFrameSlotNodeGen.create(frameSlot);
if (frameSlot == null) {
return null;
} else {
return ReadAbstractFrameSlotNodeGen.create(frameSlot);
}
}

protected boolean isLastLine(RubySymbol symbol) {
Original file line number Diff line number Diff line change
@@ -73,7 +73,9 @@ public int compare(Map.Entry<String, Source> a, Map.Entry<String, Source> b) {
public int common(String path, String existingPath) {
int n = 0;

while (n < path.length() && n < existingPath.length() && path.charAt(path.length() - n) == existingPath.charAt(existingPath.length() - n)) {
while (n < path.length()
&& n < existingPath.length()
&& path.charAt(path.length() - n - 1) == existingPath.charAt(existingPath.length() - n - 1)) {
n++;
}

2 changes: 1 addition & 1 deletion truffle/src/main/ruby/core/truffle/attachments.rb
Original file line number Diff line number Diff line change
@@ -38,7 +38,7 @@ def self.attach(file, line, &block)
# Truffle::Attachments.detach __FILE__, 21
# ```
def self.detach(file, line)
Truffle::Primitive.attach file, line
Truffle::Primitive.detach file, line
end

end

0 comments on commit 000c75d

Please sign in to comment.