A fork of Crisp for HARP
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 

45 rindas
1.2 KiB

require "../helper"
describe "Crisp::Interpreter" do
describe "#initialize" do
it "takes arguments as string value" do
i = Crisp::Interpreter.new %w(foo bar baz)
result = i.eval_string("*ARGV*")
result.should be_a(Crisp::Expr)
unwrapped = result.unwrap
unwrapped.should be_a(Crisp::List)
if unwrapped.is_a? Crisp::List
unwrapped.size.should eq(3)
a0 = unwrapped[0].unwrap
a1 = unwrapped[1].unwrap
a2 = unwrapped[2].unwrap
a0.should be_a(String)
a1.should be_a(String)
a2.should be_a(String)
a0.should eq("foo")
a1.should eq("bar")
a2.should eq("baz")
end
end
end
describe "#eval_string" do
it "evaluates string of Crisp expression" do
i = Crisp::Interpreter.new
result = i.eval_string "(+ 1 2)"
result.should be_a(Crisp::Expr)
unwrapped = result.unwrap
unwrapped.should be_a(Int32)
unwrapped.should eq(3)
end
end
describe "#run" do
it "raises eval error with file which doesn't exist" do
i = Crisp::Interpreter.new
expect_raises Crisp::EvalException do
i.run "/non/existent/file"
end
end
end
end