spec/builtins_spec.rb in rouge-lang-0.0.7 vs spec/builtins_spec.rb in rouge-lang-0.0.8
- old
+ new
@@ -152,11 +152,11 @@
end
end
describe "storing its own name" do
let(:fn) { context.readeval('(fn lmnop [])') }
-
+
it { fn.to_s.should eq :lmnop }
end
it "should compile with names bound" do
Rouge::Compiler.should_receive(:compile).
@@ -249,13 +249,13 @@
context.readeval('(do)').should eq nil
end
describe "evaluating and returning one argument" do
let(:subcontext) { Rouge::Context.new context }
-
+
before { subcontext.set_here :x, lambda {4} }
-
+
it { subcontext.readeval('(do (x))').should eq 4 }
end
# TODO: refactor & break out individual assertions
it "should evaluate multiple arguments and return the last value" do
@@ -330,10 +330,16 @@
(ns user.spec2
(:require [moop :as y])))
ROUGE
Rouge::Namespace[:y].should be Rouge::Namespace[:moop]
end
+
+ it "should refer rouge.core and ruby" do
+ context.readeval "(ns toast)"
+ Rouge[:toast].refers.should include(Rouge[:"rouge.core"])
+ Rouge[:toast].refers.should include(Rouge[:"ruby"])
+ end
end
it "should compile without compiling any of its components" do
Rouge::Compiler.should_not_receive(:compile)
Rouge::Builtins._compile_ns(ns, Set.new, Rouge::Symbol[:non_extant])
@@ -351,11 +357,11 @@
it { expect { context.readeval("(defmacro a [] b)")
}.to raise_exception Rouge::Namespace::VarNotFoundError }
describe "after readeval (def ...)" do
before { context.readeval("(def b 'c)") }
-
+
it { expect { context.readeval("(defmacro a [] b)")
}.to_not raise_exception }
end
end
@@ -403,11 +409,11 @@
Rouge::Symbol[:block]],
:foo)
end
it "should compile multi-arg form with names bound" do
- # TODO: consider breaking out these two test assertion
+ # TODO: consider breaking out these two test assertion
# blocks into their own context: they actually both fail
# in isolation but those failures are masked because
# the "Rouge::Builtins._compile_defmacro" test passes,
# and that last evaluation to 'true' gets passed as the
# return value to the enclosing 'it' method. Try it: change
@@ -416,17 +422,17 @@
#Rouge::Compiler.should_receive(:compile).
# with(ns, kind_of(Set), [:a1]) do |n, lexicals, f|
# lexicals.should eq Set[:f]
# [:a1]
#end
- #
+ #
#Rouge::Compiler.should_receive(:compile).
# with(ns, kind_of(Set), [:a2]) do |n, lexicals, f|
# lexicals.should eq Set[:g]
# [:a2]
#end
- #
+ #
Rouge::Builtins._compile_defmacro(
ns, Set.new,
Rouge::Symbol[:barge],
Rouge::Seq::Cons[[Rouge::Symbol[:f]], :a1],
Rouge::Seq::Cons[[Rouge::Symbol[:g]], :a2])
@@ -441,11 +447,11 @@
end
describe "apply" do
let(:a) { lambda {|*args| args} }
let(:subcontext) { Rouge::Context.new context }
-
+
before { subcontext.set_here :a, a }
describe "calling a function with the argument list" do
it { subcontext.readeval("(apply a [1 2 3])").should eq [1, 2, 3] }
it { subcontext.readeval("(apply a '(1 2 3))").should eq [1, 2, 3] }
@@ -643,11 +649,11 @@
context "destructuring blocks" do
let(:x) { lambda {} }
before { context.set_here :x, x }
-
+
it { context.readeval("(destructure [a | b] [1 | x])").to_s.
should eq({Rouge::Symbol[:a] => 1,
Rouge::Symbol[:b] => x}.to_s) }
end
@@ -672,10 +678,10 @@
describe "compiling the value part" do
it { expect {
Rouge::Builtins._compile_destructure(
ns, Set.new, Rouge::Symbol[:z], Rouge::Symbol[:z])
}.to raise_exception }
-
+
it { expect {
Rouge::Builtins._compile_destructure(
ns, Set[:y], Rouge::Symbol[:z], Rouge::Symbol[:y])
}.to_not raise_exception }
end