Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rubinius/rubinius
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 557507659cc4
Choose a base ref
...
head repository: rubinius/rubinius
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 07171dbe1d12
Choose a head ref
  • 2 commits
  • 6 files changed
  • 1 contributor

Commits on Dec 24, 2014

  1. Some more JIT spec setup.

    brixen committed Dec 24, 2014

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    0a547fd View commit details
  2. A few more JIT specs.

    brixen committed Dec 24, 2014
    Copy the full SHA
    07171db View commit details
Showing with 72 additions and 8 deletions.
  1. +0 −2 spec/jit/a_spec.rb
  2. +49 −1 spec/jit/method_spec.rb
  3. +5 −1 spec/jit/spec_helper.rb
  4. +7 −0 spec/jit/z_spec.rb
  5. +8 −4 spec/rbx.2.1.mspec
  6. +3 −0 spec/tags/jit/method_tags.txt
2 changes: 0 additions & 2 deletions spec/jit/a_spec.rb

This file was deleted.

50 changes: 49 additions & 1 deletion spec/jit/method_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
require File.expand_path("../spec_helper", __FILE__)

describe "JIT compiling a method call" do
context "to m()" do
before :each do
klass = Class.new do
def m() :m end
end

@o = klass.new

warmup { @o.m }
end

it "returns the last computed value" do
@o.m.should equal(:m)
end

it "raises an ArgumentError if passed an argument" do
lambda { @o.m 5 }.should raise_error(ArgumentError)
end
end

context "to m(a)" do
before :each do
klass = Class.new do
@@ -41,10 +61,38 @@ def m(*a) a end
end
end

context "to m(a: 0)" do
before :each do
klass = Class.new do
def m(a: 0) a end
end

@o = klass.new

warmup { @o.m }
end

it "returns the default keyword value when passed no arguments" do
@o.m.should == 0
end

it "returns the passed value of the keyword" do
@o.m(a: 2).should == 2
end

it "raises an ArgumentError when passed a non-matching keyword argument" do
lambda { @o.m(b: 2) }.should raise_error(ArgumentError)
end

it "raises an ArgumentError when passed extra keyword arguments" do
lambda { @o.m(a: 2, b: 3) }.should raise_error(ArgumentError)
end
end

context "to m(a=1, **kw)" do
before :each do
klass = Class.new do
def m(a=1 **kw) [a, kw] end
def m(a=1, **kw) [a, kw] end
end

@o = klass.new
6 changes: 5 additions & 1 deletion spec/jit/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require File.expand_path('../../spec_helper', __FILE__)

WARMUP_ITERATIONS = Rubinius::JIT.compile_threshold
RubiniusJITSync = Rubinius::JIT.sync
Rubinius::JIT.sync = true

WARMUP_ITERATIONS = (ENV["RBX_JIT_SPEC_ITERATIONS"] ||
Rubinius::JIT.compile_threshold).to_i

class Object
def warmup
7 changes: 7 additions & 0 deletions spec/jit/z_spec.rb
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
# TODO: Implement JIT spec infrastructure to make this hack unnecessary.
#
# During a complete spec run, this file will be loaded last and reset the JIT
# to not be in sync mode. When running a single spec file in spec/jit, the
# process will exit after running the specs so leaving the JIT in sync mode
# will not have any consequences.

Rubinius::JIT.sync = RubiniusJITSync
12 changes: 8 additions & 4 deletions spec/rbx.2.1.mspec
Original file line number Diff line number Diff line change
@@ -18,13 +18,17 @@ class MSpecScript
'spec/library',
]

# JIT specs
set :jit, [
'spec/jit',
]

# An ordered list of the directories containing specs to run
set :files, get(:language) + get(:core) + get(:library) +
set :files, get(:language) + get(:core) + get(:library) + get(:jit) +
get(:capi) + get(:compiler) + get(:build) + get(:command_line)

set :ruby, [
'spec/ruby/language',
'spec/ruby/core',
'spec/ruby',
]

# An ordered list of the directories containing specs to run
@@ -34,8 +38,8 @@ class MSpecScript
'spec/ruby/language',
'spec/ruby/command_line',
'spec/core',
'spec/jit',
'spec/language',
'spec/compiler',
'spec/command_line',
'spec/ruby/optional/capi',
'spec/library',
3 changes: 3 additions & 0 deletions spec/tags/jit/method_tags.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fails:JIT compiling a method call to m(a: 0) returns the passed value of the keyword
fails:JIT compiling a method call to m(a: 0) raises an ArgumentError when passed a non-matching keyword argument
fails:JIT compiling a method call to m(a: 0) raises an ArgumentError when passed extra keyword arguments