Skip to content

Commit

Permalink
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions spec/compiler/general_spec.rb
Original file line number Diff line number Diff line change
@@ -125,7 +125,7 @@ def compile_run(src, filename, line)

it "compiles calls" do
run("'bar'.capitalize") {|result| expect(result).to eq 'Bar' }
run("rand(10)") {|result| expect(result).to be_a_kind_of Fixnum }
run("rand(10)") {|result| expect(result).to be_a_kind_of Integer }
end

it "compiles branches" do
@@ -367,20 +367,20 @@ def self.bar
end

it "compiles class reopening" do
run("class Fixnum; def x; 3; end; end; 1.x") {|result| expect(result).to eq 3 }
run("class Integer; def x; 3; end; end; 1.x") {|result| expect(result).to eq 3 }
end

it "compiles singleton method definitions" do
run("a = 'bar'; def a.foo; 'foo'; end; a.foo") {|result| expect(result).to eq "foo" }
run("class Fixnum; def self.foo; 'foo'; end; end; Fixnum.foo") {|result| expect(result).to eq "foo" }
run("class Integer; def self.foo; 'foo'; end; end; Integer.foo") {|result| expect(result).to eq "foo" }
run("def String.foo; 'foo'; end; String.foo") {|result| expect(result).to eq "foo" }
end

it "compiles singleton class definitions" do
run("a = 'bar'; class << a; def bar; 'bar'; end; end; a.bar") {|result| expect(result).to eq "bar" }
run("class Fixnum; class << self; def bar; 'bar'; end; end; end; Fixnum.bar") {|result| expect(result).to eq "bar" }
run("class Fixnum; def self.metaclass; class << self; self; end; end; end; Fixnum.metaclass") do |result|
expect(result).to eq class << Fixnum; self; end
run("class Integer; class << self; def bar; 'bar'; end; end; end; Integer.bar") {|result| expect(result).to eq "bar" }
run("class Integer; def self.metaclass; class << self; self; end; end; end; Integer.metaclass") do |result|
expect(result).to eq class << Integer; self; end
end
end

@@ -613,10 +613,10 @@ def self.remove; remove_method :gh1239; end

it "prevents reopening or extending non-modules" do
# ensure that invalid classes and modules raise errors
AFixnum ||= 1
expect { run("class AFixnum; end")}.to raise_error(TypeError)
expect { run("class B < AFixnum; end")}.to raise_error(TypeError)
expect { run("module AFixnum; end")}.to raise_error(TypeError)
AInteger ||= 1
expect { run("class AInteger; end")}.to raise_error(TypeError)
expect { run("class B < AInteger; end")}.to raise_error(TypeError)
expect { run("module AInteger; end")}.to raise_error(TypeError)
end

it "assigns array elements properly as LHS of masgn" do
@@ -1139,7 +1139,7 @@ def self.foo
end
end

it "compiles calls with one fixnum arg that do not have optimized paths" do
it "compiles calls with one Integer arg that do not have optimized paths" do
run('ary = []; ary.push(1)') {|x| expect(x).to eq([1]) }
end

0 comments on commit 510e937

Please sign in to comment.