Sha256: 5ff9aab9d286b16413be2bdaece55db5911561df6e564aaadf1fa4e13c961f33
Contents?: true
Size: 1.62 KB
Versions: 1
Compression:
Stored size: 1.62 KB
Contents
describe "procedure calls" do let(:empty_args) { VarTuple.new [] } let(:empty_body) { CmdBlock.empty } it "should execute an existing procedure when calling it" do poner_cmd = Poner.new Verde.new body = CmdBlock.new [poner_cmd] my_procedure = Procedure.new 'MyProcedure', empty_args, body program = Program.new [my_procedure], nil context = ProgramExecutionContext.for program proc_call = ProcedureCall.new 'MyProcedure', [] proc_call.evaluate context expect(context.head.are_there_balls?(Verde.new)).to be_true end it "should allow to call a procedure from another procedure" do poner_cmd = Poner.new Azul.new inner_procedure_body = CmdBlock.new [poner_cmd] inner_procedure = Procedure.new 'Inner', empty_args, inner_procedure_body call_to_inner_procedure = ProcedureCall.new 'Inner', [] outer_procedure_body = CmdBlock.new [call_to_inner_procedure] outer_procedure = Procedure.new 'Outer', empty_args, outer_procedure_body program = Program.new [outer_procedure, inner_procedure], nil program_context = ProgramExecutionContext.for program call_to_outer_procedure = ProcedureCall.new 'Outer', [] call_to_outer_procedure.evaluate program_context expect(program_context.head.are_there_balls?(Azul.new)).to be_true end it "should fail to execute an undefined procedure" do program = Program.new [], nil context = ProgramExecutionContext.for program proc_call = ProcedureCall.new 'UndefinedProcedure', [] expect { proc_call.evaluate context } .to raise_error(DefinitionNotFound, DefinitionNotFound.message_for('UndefinedProcedure')) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
gobstones-0.0.1.1 | spec/lang/commands/procedure_call_spec.rb |