Skip to content

Commit

Permalink
Merge branch 'master' into truffle-head
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed May 9, 2015
2 parents 01c49d7 + 000c75d commit 5de0ab0
Show file tree
Hide file tree
Showing 45 changed files with 815 additions and 10 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -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:
Expand Down
14 changes: 11 additions & 3 deletions pom.rb
Expand Up @@ -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

Expand Down
9 changes: 9 additions & 0 deletions pom.xml
Expand Up @@ -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>
Expand Down
80 changes: 80 additions & 0 deletions spec/truffle/specs/truffle/attachments/attach_spec.rb
@@ -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
@@ -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
@@ -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
@@ -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
@@ -0,0 +1 @@
VALUE add(VALUE self, VALUE a, VALUE b);
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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

0 comments on commit 5de0ab0

Please sign in to comment.