Skip to content

Commit

Permalink
Properly guard JIT specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
brixen committed Aug 30, 2015
1 parent 9dd6f73 commit c808b9b
Show file tree
Hide file tree
Showing 4 changed files with 197 additions and 187 deletions.
140 changes: 71 additions & 69 deletions spec/jit/call_site_spec.rb
@@ -1,100 +1,102 @@
require File.expand_path("../spec_helper", __FILE__)

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

@o = klass.new

jit(@o, :call) { @o.call }
end

@o = klass.new
it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end

jit(@o, :call) { @o.call }
it "returns the result of calling the method" do
@o.call.should equal(:m)
end
end

it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end
context "to m() defined in an included module" do
before :each do
mod = Module.new do
def m() :m end
end
klass = Class.new do
def call() m() end
include mod
end

it "returns the result of calling the method" do
@o.call.should equal(:m)
end
end
@o = klass.new

context "to m() defined in an included module" do
before :each do
mod = Module.new do
def m() :m end
end
klass = Class.new do
def call() m() end
include mod
jit(@o, :call) { @o.call }
end

@o = klass.new
it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end

jit(@o, :call) { @o.call }
it "returns the result of calling the included method" do
@o.call.should equal(:m)
end
end

it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end
context "to m() defined in a prepended module" do
before :each do

it "returns the result of calling the included method" do
@o.call.should equal(:m)
end
end
mod = Module.new do
def m() :m end
end
klass = Class.new do
def m() :shadowed end
def call() m() end
prepend mod
end

context "to m() defined in a prepended module" do
before :each do
o = @o = klass.new

mod = Module.new do
def m() :m end
end
klass = Class.new do
def m() :shadowed end
def call() m() end
prepend mod
jit(o, :call) { o.call }
end

o = @o = klass.new
it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end

jit(o, :call) { o.call }
it "returns the result of calling the prepended method" do
@o.call.should equal(:m)
end
end

it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end
context "to m() that calls super defined in a prepended module" do
before :each do

it "returns the result of calling the prepended method" do
@o.call.should equal(:m)
end
end
mod = Module.new do
def m() super; :m end
end
klass = Class.new do
def m() :shadowed end
def call() m() end
prepend mod
end

context "to m() that calls super defined in a prepended module" do
before :each do
o = @o = klass.new

mod = Module.new do
def m() super; :m end
end
klass = Class.new do
def m() :shadowed end
def call() m() end
prepend mod
jit(o, :call) { o.call }
end

o = @o = klass.new

jit(o, :call) { o.call }
end

it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end
it "compiles" do
@o.method(:call).executable.jitted?.should be_true
end

it "returns the result of calling the prepended method" do
@o.call.should equal(:m)
it "returns the result of calling the prepended method" do
@o.call.should equal(:m)
end
end
end
end
28 changes: 15 additions & 13 deletions spec/jit/instruction_spec.rb
@@ -1,21 +1,23 @@
require File.expand_path("../spec_helper", __FILE__)

describe "JIT compiling a string_dup instruction" do
before :each do
klass = Class.new do
def m() "abc" end
end
with_feature :jit do
describe "JIT compiling a string_dup instruction" do
before :each do
klass = Class.new do
def m() "abc" end
end

@o = klass.new
@o = klass.new

jit(@o, :m) { @o.m }
end
jit(@o, :m) { @o.m }
end

it "compiles" do
@o.method(:m).executable.jitted?.should be_true
end
it "compiles" do
@o.method(:m).executable.jitted?.should be_true
end

it "dups the literal String" do
@o.method(:m).executable.literals[0].object_id.should_not equal(@o.m)
it "dups the literal String" do
@o.method(:m).executable.literals[0].object_id.should_not equal(@o.m)
end
end
end

0 comments on commit c808b9b

Please sign in to comment.