Skip to content

Commit

Permalink
Some refactors in specs for not requiring prelude, and some typos fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ary Borenszweig committed Feb 12, 2014
1 parent 4519ce0 commit 418eab3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
17 changes: 15 additions & 2 deletions spec/compiler/codegen/def_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,28 @@ describe "Code gen: def" do
end

it "call external function 'putchar'" do
run("require \"c\"; require \"io\"; C.putchar '\\0'").to_i.should eq(0)
run("
lib C
fun putchar(c : Char) : Char
end
C.putchar '\\0'
").to_i.should eq(0)
end

it "uses self" do
run("struct Int; def foo; self + 1; end; end; 3.foo").to_i.should eq(4)
end

it "uses var after external" do
run("require \"c\"; require \"io\"; a = 1; C.putchar '\\0'; a").to_i.should eq(1)
run("
lib C
fun putchar(c : Char) : Char
end
a = 1
C.putchar '\\0'
a
").to_i.should eq(1)
end

it "allows to change argument values" do
Expand Down
6 changes: 3 additions & 3 deletions spec/compiler/codegen/responds_to_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ describe "Codegen: responds_to?" do
run("(1 == 1 ? 1 : 'a').responds_to?(:\"foo\")").to_b.should be_false
end

it "codegens is_a? with nilable gives true" do
it "codegens responds_to? with nilable gives true" do
run("struct Nil; def foo; end; end; (1 == 1 ? nil : Reference.new).responds_to?(:foo)").to_b.should be_true
end

it "codegens is_a? with nilable gives false becuase other type 1" do
it "codegens responds_to? with nilable gives false becuase other type 1" do
run("(1 == 1 ? nil : Reference.new).responds_to?(:foo)").to_b.should be_false
end

it "codegens is_a? with nilable gives false becuase other type 2" do
it "codegens responds_to? with nilable gives false becuase other type 2" do
run("class Reference; def foo; end; end; (1 == 2 ? nil : Reference.new).responds_to?(:foo)").to_b.should be_true
end
end

0 comments on commit 418eab3

Please sign in to comment.