spec/parser/gobstones_program_spec.rb in gobstones-0.0.1.1 vs spec/parser/gobstones_program_spec.rb in gobstones-0.0.2
- old
+ new
@@ -1,18 +1,18 @@
describe Gobstones::Parser, "program definitions" do
- it "should parse a simple program with a single main" do
- main_def = Main.new CmdBlock.new([]), NoReturnStatement.new
- program = Program.new [], main_def
+ it "parses a simple program with a single main" do
+ main_def = Main.new empty_body, no_return_statement
+ program = Program.new no_definitions, main_def
expect('procedure Main(){}').to be_parsed_as(:program).and_return(program)
end
- it "should parse a program with Main and procedures" do
- main_def = Main.new CmdBlock.new([]), NoReturnStatement.new
- proc_1 = Procedure.new 'Procedure1', VarTuple.new([]), CmdBlock.new([])
- proc_2 = Procedure.new 'Procedure2', VarTuple.new([]), CmdBlock.new([])
+ it "parses a program with Main and procedures" do
+ main_def = Main.new empty_body, no_return_statement
+ proc_1 = Procedure.new 'Procedure1', no_arguments, empty_body
+ proc_2 = Procedure.new 'Procedure2', no_arguments, empty_body
program = Program.new [proc_1, proc_2], main_def
gbs_code = <<GBS
procedure Procedure1(){ }
@@ -21,15 +21,15 @@
procedure Main() {}
GBS
expect(gbs_code).to be_parsed_as(:program).and_return(program)
end
- it "should parse a program with Main, procedures and functions" do
- main_def = Main.new CmdBlock.new([]), NoReturnStatement.new
- proc_1 = Procedure.new 'Procedure1', VarTuple.new([]), CmdBlock.new([])
- func_1 = Function.new 'function1', VarTuple.new([]), CmdBlock.new([]), ReturnFromFunction.new([42.to_gbs_num])
- proc_2 = Procedure.new 'Procedure2', VarTuple.new([]), CmdBlock.new([])
+ it "parses a program with Main, procedures and functions" do
+ main_def = Main.new empty_body, NoReturnStatement.new
+ proc_1 = Procedure.new 'Procedure1', no_arguments, empty_body
+ func_1 = Function.new 'function1', no_arguments, empty_body, ReturnFromFunction.new([42.to_gbs_num])
+ proc_2 = Procedure.new 'Procedure2', no_arguments, empty_body
program = Program.new [proc_1, func_1, proc_2], main_def
gbs_code = <<GBS
procedure Procedure1(){ }
function function1() { return (42) }
@@ -39,17 +39,17 @@
procedure Main() {}
GBS
expect(gbs_code).to be_parsed_as(:program).and_return(program)
end
- it "should not parse a program without a Main definition" do
+ it "does not parse a program without a Main definition" do
expect('procedure Procedure1(){}
procedure Procedure2() {}').to be_parsed_as(:program).and_fail
end
- it "should not parse a program if Main is not the last definition" do
+ it "does not parse a program if Main is not the last definition" do
expect('procedure Procedure1() {}
procedure Main() {}
procedure Procedure2() {}').to be_parsed_as(:program).and_fail
end
-end
\ No newline at end of file
+end