Przeglądaj źródła

add spec for Interpreter#initialize

master
rhysd 9 lat temu
rodzic
commit
55e101bdea
1 zmienionych plików z 24 dodań i 1 usunięć
  1. +24
    -1
      spec/crisp/interpreter_spec.cr

+ 24
- 1
spec/crisp/interpreter_spec.cr Wyświetl plik

@ -1,6 +1,28 @@
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::Type)
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
@ -14,8 +36,9 @@ describe "Crisp::Interpreter" do
describe "#run" do
it "raises eval error with file which doesn't exist" do
i = Crisp::Interpreter.new
expect_raises Crisp::EvalException do
Crisp::Interpreter.new "/non/existent/file"
i.run "/non/existent/file"
end
end
end

Ładowanie…
Anuluj
Zapisz