diff --git a/spec/lang/commands/assignments_spec.rb b/spec/lang/commands/assignments_spec.rb index f966062..3c2aaec 100644 --- a/spec/lang/commands/assignments_spec.rb +++ b/spec/lang/commands/assignments_spec.rb @@ -6,8 +6,8 @@ it "should associate the var name with the evaluated expression" do assign = SingleAssignment.new a, Add.new(3.to_gbs_num, 4.to_gbs_num) assign.evaluate context - context.has_variable_named?('a').should be_true - context.get(a).should == 7.to_gbs_num + expect(context.has_variable_named?('a')).to be_true + expect(context.get(a)).to eq(7.to_gbs_num) end end \ No newline at end of file diff --git a/spec/lang/commands/cmd_block_spec.rb b/spec/lang/commands/cmd_block_spec.rb index 3358fc7..0be5516 100644 --- a/spec/lang/commands/cmd_block_spec.rb +++ b/spec/lang/commands/cmd_block_spec.rb @@ -7,10 +7,10 @@ Poner.new(Rojo.new), Poner.new(Verde.new), Poner.new(Negro.new), Poner.new(Azul.new)] cmd_block.evaluate context - context.head.are_there_balls?(Rojo.new).should be_true - context.head.are_there_balls?(Azul.new).should be_true - context.head.are_there_balls?(Negro.new).should be_true - context.head.are_there_balls?(Verde.new).should be_true + expect(context.head.are_there_balls?(Rojo.new)).to be_true + expect(context.head.are_there_balls?(Azul.new)).to be_true + expect(context.head.are_there_balls?(Negro.new)).to be_true + expect(context.head.are_there_balls?(Verde.new)).to be_true end it "builds an empty command block" do diff --git a/spec/lang/commands/if_cmd_spec.rb b/spec/lang/commands/if_cmd_spec.rb index 7f76af3..dd4663e 100644 --- a/spec/lang/commands/if_cmd_spec.rb +++ b/spec/lang/commands/if_cmd_spec.rb @@ -9,13 +9,13 @@ it "should evaluate the block if the condition is true" do if_cmd = IfCmd.new True.new, then_block if_cmd.evaluate context - context.head.are_there_balls?(Verde.new).should be_true + expect(context.head.are_there_balls?(Verde.new)).to be_true end it "should not evaluate the block if the condition is false" do if_cmd = IfCmd.new False.new, then_block if_cmd.evaluate context - context.head.are_there_balls?(Verde.new).should be_false + expect(context.head.are_there_balls?(Verde.new)).to be_false end it "should raise a type error if the condition is not boolean" do @@ -33,15 +33,15 @@ it "should evaluate the 'then' block and not evaluate the 'else' block" do if_cmd = IfElseCmd.new True.new, then_block, else_block if_cmd.evaluate context - context.head.are_there_balls?(Verde.new).should be_true - context.head.are_there_balls?(Rojo.new).should be_false + expect(context.head.are_there_balls?(Verde.new)).to be_true + expect(context.head.are_there_balls?(Rojo.new)).to be_false end it "should not evaluate the 'then' block and evaluate the 'else' block" do if_cmd = IfElseCmd.new False.new, then_block, else_block if_cmd.evaluate context - context.head.are_there_balls?(Verde.new).should be_false - context.head.are_there_balls?(Rojo.new).should be_true + expect(context.head.are_there_balls?(Verde.new)).to be_false + expect(context.head.are_there_balls?(Rojo.new)).to be_true end end diff --git a/spec/lang/commands/ir_al_origen_cmd_spec.rb b/spec/lang/commands/ir_al_origen_cmd_spec.rb index dc09ea0..1c9505e 100644 --- a/spec/lang/commands/ir_al_origen_cmd_spec.rb +++ b/spec/lang/commands/ir_al_origen_cmd_spec.rb @@ -9,8 +9,8 @@ ir_al_origen.evaluate context - context.head.x_pos.should == 0 - context.head.y_pos.should == 0 + expect(context.head.x_pos).to eq(0) + expect(context.head.y_pos).to eq(0) end end \ No newline at end of file diff --git a/spec/lang/commands/mover_cmd_spec.rb b/spec/lang/commands/mover_cmd_spec.rb index c7c4ba6..97f9ab8 100644 --- a/spec/lang/commands/mover_cmd_spec.rb +++ b/spec/lang/commands/mover_cmd_spec.rb @@ -7,8 +7,8 @@ it "should run" do Mover.new(north).evaluate(context) - context.head.x_pos.should == 0 - context.head.y_pos.should == 1 + expect(context.head.x_pos).to eq(0) + expect(context.head.y_pos).to eq(1) end it "should undo" do @@ -17,12 +17,12 @@ cmd.evaluate context cmd.undo context - context.head.x_pos.should == 0 - context.head.y_pos.should == 0 + expect(context.head.x_pos).to eq(0) + expect(context.head.y_pos).to eq(0) end it "should return opposite cmd" do - Mover.new(north).opposite.should == Mover.new(south) + expect(Mover.new(north).opposite).to eq(Mover.new(south)) end it "should fail if types don't match" do diff --git a/spec/lang/commands/poner_cmd_spec.rb b/spec/lang/commands/poner_cmd_spec.rb index b86843d..efa925b 100644 --- a/spec/lang/commands/poner_cmd_spec.rb +++ b/spec/lang/commands/poner_cmd_spec.rb @@ -6,7 +6,7 @@ it "should execute" do Poner.new(green).evaluate(context) - context.head.number_of_balls(green).should == 1 + expect(context.head.number_of_balls(green)).to eq(1) end it "should undo" do @@ -14,11 +14,11 @@ Poner.new(green).undo context - context.head.number_of_balls(green).should == 0 + expect(context.head.number_of_balls(green)).to eq(0) end it "should return the opposite cmd" do - Poner.new(green).opposite.should == Sacar.new(green) + expect(Poner.new(green).opposite).to eq(Sacar.new(green)) end it "should fail if types don't match" do diff --git a/spec/lang/commands/procedure_call_spec.rb b/spec/lang/commands/procedure_call_spec.rb index bde67a7..b1561c8 100644 --- a/spec/lang/commands/procedure_call_spec.rb +++ b/spec/lang/commands/procedure_call_spec.rb @@ -13,7 +13,7 @@ proc_call = ProcedureCall.new 'MyProcedure', [] proc_call.evaluate context - context.head.are_there_balls?(Verde.new).should be_true + expect(context.head.are_there_balls?(Verde.new)).to be_true end it "should allow to call a procedure from another procedure" do @@ -29,7 +29,7 @@ call_to_outer_procedure = ProcedureCall.new 'Outer', [] call_to_outer_procedure.evaluate program_context - program_context.head.are_there_balls?(Azul.new).should be_true + expect(program_context.head.are_there_balls?(Azul.new)).to be_true end it "should fail to execute an undefined procedure" do diff --git a/spec/lang/commands/procedure_spec.rb b/spec/lang/commands/procedure_spec.rb index 6f3277d..90ee99e 100644 --- a/spec/lang/commands/procedure_spec.rb +++ b/spec/lang/commands/procedure_spec.rb @@ -9,7 +9,7 @@ body = CmdBlock.new [poner_cmd] procedure = Procedure.new 'MyProcedure', empty_args, body procedure.evaluate program_context - program_context.head.are_there_balls?(Rojo.new).should be_true + expect(program_context.head.are_there_balls?(Rojo.new)).to be_true end it "should execute in a new clean context, without having variables defined in another contexts" do @@ -34,8 +34,8 @@ procedure.evaluate program_context, [Negro.new, Norte.new] - program_context.head.are_there_balls?(Negro.new).should be_true - program_context.head.y_pos.should == 1 + expect(program_context.head.are_there_balls?(Negro.new)).to be_true + expect(program_context.head.y_pos).to eq(1) end it "should not set arguments as var names in outer context" do @@ -45,7 +45,7 @@ procedure.evaluate program_context, [Oeste.new] - program_context.has_variable_named?('a_direction').should be_false + expect(program_context.has_variable_named?('a_direction')).to be_false end it "should fail if it is executed with more arguments than expected" do diff --git a/spec/lang/commands/repeat_with_cmd_spec.rb b/spec/lang/commands/repeat_with_cmd_spec.rb index d8987a4..1269e54 100644 --- a/spec/lang/commands/repeat_with_cmd_spec.rb +++ b/spec/lang/commands/repeat_with_cmd_spec.rb @@ -6,7 +6,7 @@ it "should iterate over numbers" do repeat_with = RepeatWithCmd.new var_name, 1.to_gbs_num, 10.to_gbs_num, CmdBlock.new([Poner.new(Rojo.new)]) repeat_with.evaluate context - context.head.number_of_balls(Rojo.new).should == 10 + expect(context.head.number_of_balls(Rojo.new)).to eq(10) end it "should throw an error if the range values have not the same type" do @@ -25,17 +25,17 @@ it "should remove the index variable assignment after execution" do repeat_with = RepeatWithCmd.new var_name, Azul.new, Verde.new, CmdBlock.new([]) repeat_with.evaluate context - context.has_variable_named?('var').should be_false + expect(context.has_variable_named?('var')).to be_false end it "should allow to use the index variable inside the command block" do cmd_block = CmdBlock.new [Poner.new(VarName.new('var'))] repeat_with = RepeatWithCmd.new var_name, Azul.new, Verde.new, cmd_block repeat_with.evaluate context - context.head.are_there_balls?(Azul.new).should be_true - context.head.are_there_balls?(Negro.new).should be_true - context.head.are_there_balls?(Rojo.new).should be_true - context.head.are_there_balls?(Verde.new).should be_true + expect(context.head.are_there_balls?(Azul.new)).to be_true + expect(context.head.are_there_balls?(Negro.new)).to be_true + expect(context.head.are_there_balls?(Rojo.new)).to be_true + expect(context.head.are_there_balls?(Verde.new)).to be_true end end \ No newline at end of file diff --git a/spec/lang/commands/sacar_cmd_spec.rb b/spec/lang/commands/sacar_cmd_spec.rb index 5e41060..360370b 100644 --- a/spec/lang/commands/sacar_cmd_spec.rb +++ b/spec/lang/commands/sacar_cmd_spec.rb @@ -8,17 +8,17 @@ Sacar.new(red).evaluate context - context.head.number_of_balls(red).should == 2 + expect(context.head.number_of_balls(red)).to eq(2) end it "should undo" do Sacar.new(red).undo context - context.head.number_of_balls(red).should == 1 + expect(context.head.number_of_balls(red)).to eq(1) end it "should return the opposite cmd" do - Sacar.new(red).opposite.should == Poner.new(red) + expect(Sacar.new(red).opposite).to eq(Poner.new(red)) end it "should fail if there are no balls in the board" do diff --git a/spec/lang/commands/vaciar_tablero_cmd_spec.rb b/spec/lang/commands/vaciar_tablero_cmd_spec.rb index e881dd9..a9a9e13 100644 --- a/spec/lang/commands/vaciar_tablero_cmd_spec.rb +++ b/spec/lang/commands/vaciar_tablero_cmd_spec.rb @@ -7,7 +7,7 @@ context.head.put red vaciar_tablero = VaciarTablero.new vaciar_tablero.evaluate context - context.board.empty?.should be_true + expect(context.board.empty?).to be_true end end \ No newline at end of file diff --git a/spec/lang/commands/while_cmd_spec.rb b/spec/lang/commands/while_cmd_spec.rb index 08c74a9..814668f 100644 --- a/spec/lang/commands/while_cmd_spec.rb +++ b/spec/lang/commands/while_cmd_spec.rb @@ -6,20 +6,20 @@ def condition(times) cond = double('while condition') expected_values = [True.new] * times + [False.new] - cond.stub(:evaluate).and_return(*expected_values) + allow(cond).to receive(:evaluate).and_return(*expected_values) cond end it "should evaluate the command block until the condition is not satisfied" do while_cmd = WhileCmd.new condition(3), while_block while_cmd.evaluate context - context.head.number_of_balls(Verde.new).should == 3 + expect(context.head.number_of_balls(Verde.new)).to eq(3) end it "should not evaluate the command block if the condition is not satisfied" do while_cmd = WhileCmd.new condition(0), while_block while_cmd.evaluate context - context.head.are_there_balls?(Verde.new).should be_false + expect(context.head.are_there_balls?(Verde.new)).to be_false end it "should raise a type error if the condition is not boolean" do diff --git a/spec/lang/expressions/arithmetic_expressions_spec.rb b/spec/lang/expressions/arithmetic_expressions_spec.rb index 1d9b417..1a2db16 100644 --- a/spec/lang/expressions/arithmetic_expressions_spec.rb +++ b/spec/lang/expressions/arithmetic_expressions_spec.rb @@ -4,7 +4,7 @@ it "should evaluate with two numbers" do add = Add.new(42.to_gbs_num, 23.to_gbs_num) - add.evaluate.should == 65.to_gbs_num + expect(add.evaluate).to eq(65.to_gbs_num) end it "should evaluate nested add expressions" do @@ -14,7 +14,7 @@ add_43_23 = Add.new add_27_16, 23.to_gbs_num add_66_42 = Add.new add_43_23, 42.to_gbs_num - add_66_42.evaluate.should == 108.to_gbs_num + expect(add_66_42.evaluate).to eq(108.to_gbs_num) end end @@ -23,19 +23,19 @@ it "should evaluate with two numbers" do sub = Sub.new(42.to_gbs_num, 15.to_gbs_num) - sub.evaluate.should == 27.to_gbs_num + expect(sub.evaluate).to eq(27.to_gbs_num) end it "should evaluate and return a negative result" do sub = Sub.new(15.to_gbs_num, 42.to_gbs_num) - sub.evaluate.should == -27.to_gbs_num + expect(sub.evaluate).to eq(-27.to_gbs_num) end it "should evaluate nested sub expressions" do sub_n1_n2 = Sub.new 42.to_gbs_num, 15.to_gbs_num sub = Sub.new sub_n1_n2, 8.to_gbs_num - sub.evaluate.should == 19.to_gbs_num + expect(sub.evaluate).to eq(19.to_gbs_num) end end @@ -44,12 +44,12 @@ it "should evaluate a simple mul" do mul = Mul.new(4.to_gbs_num, 8.to_gbs_num) - mul.evaluate.should == 32.to_gbs_num + expect(mul.evaluate).to eq(32.to_gbs_num) end it "should evaluate a nested mul expression" do mul = Mul.new(-2.to_gbs_num, 4.to_gbs_num) - Mul.new(mul, 5.to_gbs_num).evaluate.should == -40.to_gbs_num + expect(Mul.new(mul, 5.to_gbs_num).evaluate).to eq(-40.to_gbs_num) end end @@ -58,12 +58,12 @@ it "should evaluate a simple div" do div = Div.new(12.to_gbs_num, 3.to_gbs_num) - div.evaluate.should == 4.to_gbs_num + expect(div.evaluate).to eq(4.to_gbs_num) end it "should evaluate to an integer division" do div = Div.new(10.to_gbs_num, 3.to_gbs_num) - div.evaluate.should == 3.to_gbs_num + expect(div.evaluate).to eq(3.to_gbs_num) end it "should raise an error when dividing by zero" do @@ -78,12 +78,12 @@ it "should evaluate a mod with result 0" do mod = Mod.new(4.to_gbs_num, 4.to_gbs_num) - mod.evaluate.should == 0.to_gbs_num + expect(mod.evaluate).to eq(0.to_gbs_num) end it "should evaluate a mod with result > 0" do mod = Mod.new(10.to_gbs_num, 3.to_gbs_num) - mod.evaluate.should == 1.to_gbs_num + expect(mod.evaluate).to eq(1.to_gbs_num) end end @@ -94,13 +94,13 @@ pow_1 = Pow.new(1.to_gbs_num, 0.to_gbs_num) pow_42 = Pow.new(42.to_gbs_num, 0.to_gbs_num) - pow_1.evaluate.should == 1.to_gbs_num - pow_42.evaluate.should == 1.to_gbs_num + expect(pow_1.evaluate).to eq(1.to_gbs_num) + expect(pow_42.evaluate).to eq(1.to_gbs_num) end it "should calculate 2 raised to 4" do pow = Pow.new(2.to_gbs_num, 4.to_gbs_num) - pow.evaluate.should == 16.to_gbs_num + expect(pow.evaluate).to eq(16.to_gbs_num) end end diff --git a/spec/lang/expressions/boolean_expressions_spec.rb b/spec/lang/expressions/boolean_expressions_spec.rb index e24e06d..85bb92c 100644 --- a/spec/lang/expressions/boolean_expressions_spec.rb +++ b/spec/lang/expressions/boolean_expressions_spec.rb @@ -8,10 +8,10 @@ describe And do it "should evaluate a simple and expression" do - And.new(false_value, false_value).evaluate.should == false_value - And.new(false_value, true_value).evaluate.should == false_value - And.new(true_value, false_value).evaluate.should == false_value - And.new(true_value, true_value).evaluate.should == true_value + expect(And.new(false_value, false_value).evaluate).to eq(false_value) + expect(And.new(false_value, true_value).evaluate).to eq(false_value) + expect(And.new(true_value, false_value).evaluate).to eq(false_value) + expect(And.new(true_value, true_value).evaluate).to eq(true_value) end end @@ -19,10 +19,10 @@ describe Or do it "should evaluate a simple or expression" do - Or.new(false_value, false_value).evaluate.should == false_value - Or.new(false_value, true_value).evaluate.should == true_value - Or.new(true_value, false_value).evaluate.should == true_value - Or.new(true_value, true_value).evaluate.should == true_value + expect(Or.new(false_value, false_value).evaluate).to eq(false_value) + expect(Or.new(false_value, true_value).evaluate).to eq(true_value) + expect(Or.new(true_value, false_value).evaluate).to eq(true_value) + expect(Or.new(true_value, true_value).evaluate).to eq(true_value) end end @@ -30,13 +30,13 @@ describe Not do it "should evaluate a simple not expression" do - Not.new(false_value).evaluate.should == true_value - Not.new(true_value).evaluate.should == false_value + expect(Not.new(false_value).evaluate).to eq(true_value) + expect(Not.new(true_value).evaluate).to eq(false_value) end it "should evaluate a not not expression" do - Not.new(Not.new(false_value)).evaluate.should == false_value - Not.new(Not.new(true_value)).evaluate.should == true_value + expect(Not.new(Not.new(false_value)).evaluate).to eq(false_value) + expect(Not.new(Not.new(true_value)).evaluate).to eq(true_value) end end @@ -44,11 +44,11 @@ describe "nested" do it "should evaluate and's and or's" do - And.new(Or.new(false_value, true_value), true_value).evaluate.should == true_value + expect(And.new(Or.new(false_value, true_value), true_value).evaluate).to eq(true_value) end it "should evaluate and's, or's, and not's" do - Not.new(Or.new(false_value, And.new(true_value, true_value))).evaluate.should == false_value + expect(Not.new(Or.new(false_value, And.new(true_value, true_value))).evaluate).to eq(false_value) end end diff --git a/spec/lang/expressions/comparison_expressions_spec.rb b/spec/lang/expressions/comparison_expressions_spec.rb index 671573f..f3afc3b 100644 --- a/spec/lang/expressions/comparison_expressions_spec.rb +++ b/spec/lang/expressions/comparison_expressions_spec.rb @@ -6,20 +6,20 @@ describe Equal do it "should evaluate same booleans as equal" do - Equal.new(false_value, false_value).evaluate.should == true_value - Equal.new(true_value, true_value).evaluate.should == true_value - Equal.new(false_value, true_value).evaluate.should == false_value - Equal.new(true_value, false_value).evaluate.should == false_value + expect(Equal.new(false_value, false_value).evaluate).to eq(true_value) + expect(Equal.new(true_value, true_value).evaluate).to eq(true_value) + expect(Equal.new(false_value, true_value).evaluate).to eq(false_value) + expect(Equal.new(true_value, false_value).evaluate).to eq(false_value) end it "should evaluate same colors as equal" do color_classes = [Azul, Negro, Rojo, Verde] color_classes.each do |color_class| - Equal.new(color_class.new, color_class.new). - evaluate.should == true_value + expect(Equal.new(color_class.new, color_class.new). + evaluate).to eq(true_value) (color_classes - [color_class]).each do |different_color_class| - Equal.new(color_class.new, different_color_class.new). - evaluate.should == false_value + expect(Equal.new(color_class.new, different_color_class.new). + evaluate).to eq(false_value) end end end @@ -27,18 +27,18 @@ it "should evaluate same directions as equal" do dir_classes = [Norte, Sur, Este, Oeste] dir_classes.each do |dir_class| - Equal.new(dir_class.new, dir_class.new). - evaluate.should == true_value + expect(Equal.new(dir_class.new, dir_class.new). + evaluate).to eq(true_value) (dir_classes - [dir_class]).each do |different_dir_class| - Equal.new(dir_class.new, different_dir_class.new). - evaluate.should == false_value + expect(Equal.new(dir_class.new, different_dir_class.new). + evaluate).to eq(false_value) end end end it "should evaluate same numbers as equal" do - Equal.new(42.to_gbs_num, 42.to_gbs_num).evaluate.should == true_value - Equal.new(42.to_gbs_num, 15.to_gbs_num).evaluate.should == false_value + expect(Equal.new(42.to_gbs_num, 42.to_gbs_num).evaluate).to eq(true_value) + expect(Equal.new(42.to_gbs_num, 15.to_gbs_num).evaluate).to eq(false_value) end end @@ -46,20 +46,20 @@ describe NotEqual do it "should evaluate booleans as not equal" do - NotEqual.new(false_value, false_value).evaluate.should == false_value - NotEqual.new(true_value, true_value).evaluate.should == false_value - NotEqual.new(false_value, true_value).evaluate.should == true_value - NotEqual.new(true_value, false_value).evaluate.should == true_value + expect(NotEqual.new(false_value, false_value).evaluate).to eq(false_value) + expect(NotEqual.new(true_value, true_value).evaluate).to eq(false_value) + expect(NotEqual.new(false_value, true_value).evaluate).to eq(true_value) + expect(NotEqual.new(true_value, false_value).evaluate).to eq(true_value) end it "should evaluate same colors as equal" do color_classes = [Azul, Negro, Rojo, Verde] color_classes.each do |color_class| - NotEqual.new(color_class.new, color_class.new). - evaluate.should == false_value + expect(NotEqual.new(color_class.new, color_class.new). + evaluate).to eq(false_value) (color_classes - [color_class]).each do |different_color_class| - NotEqual.new(color_class.new, different_color_class.new). - evaluate.should == true_value + expect(NotEqual.new(color_class.new, different_color_class.new). + evaluate).to eq(true_value) end end end @@ -67,18 +67,18 @@ it "should evaluate same directions as equal" do dir_classes = [Norte, Sur, Este, Oeste] dir_classes.each do |dir_class| - NotEqual.new(dir_class.new, dir_class.new). - evaluate.should == false_value + expect(NotEqual.new(dir_class.new, dir_class.new). + evaluate).to eq(false_value) (dir_classes - [dir_class]).each do |different_dir_class| - NotEqual.new(dir_class.new, different_dir_class.new). - evaluate.should == true_value + expect(NotEqual.new(dir_class.new, different_dir_class.new). + evaluate).to eq(true_value) end end end it "should evaluate same numbers as equal" do - NotEqual.new(42.to_gbs_num, 42.to_gbs_num).evaluate.should == false_value - NotEqual.new(42.to_gbs_num, 15.to_gbs_num).evaluate.should == true_value + expect(NotEqual.new(42.to_gbs_num, 42.to_gbs_num).evaluate).to eq(false_value) + expect(NotEqual.new(42.to_gbs_num, 15.to_gbs_num).evaluate).to eq(true_value) end end @@ -86,33 +86,33 @@ describe LessThan do it "should evaluate for booleans" do - LessThan.new(false_value, false_value).evaluate.should == false_value - LessThan.new(false_value, true_value).evaluate.should == true_value - LessThan.new(true_value, false_value).evaluate.should == false_value - LessThan.new(true_value, true_value).evaluate.should == false_value + expect(LessThan.new(false_value, false_value).evaluate).to eq(false_value) + expect(LessThan.new(false_value, true_value).evaluate).to eq(true_value) + expect(LessThan.new(true_value, false_value).evaluate).to eq(false_value) + expect(LessThan.new(true_value, true_value).evaluate).to eq(false_value) end it "should evaluate for numbers" do - LessThan.new(15.to_gbs_num, 42.to_gbs_num).evaluate.should == true_value - LessThan.new(42.to_gbs_num, 15.to_gbs_num).evaluate.should == false_value - LessThan.new(42.to_gbs_num, 42.to_gbs_num).evaluate.should == false_value + expect(LessThan.new(15.to_gbs_num, 42.to_gbs_num).evaluate).to eq(true_value) + expect(LessThan.new(42.to_gbs_num, 15.to_gbs_num).evaluate).to eq(false_value) + expect(LessThan.new(42.to_gbs_num, 42.to_gbs_num).evaluate).to eq(false_value) end it "should evaluate for colors" do color_classes = Color.order color_classes.each_with_index do |color_class, index| # should not be less than itself - LessThan.new(color_class.new, color_class.new). - evaluate.should == false_value + expect(LessThan.new(color_class.new, color_class.new). + evaluate).to eq(false_value) color_classes.take(index).each do |previous_color_class| # should not be less than any previous value - LessThan.new(color_class.new, previous_color_class.new). - evaluate.should == false_value + expect(LessThan.new(color_class.new, previous_color_class.new). + evaluate).to eq(false_value) end color_classes.drop(index+1).each do |next_color_class| # should be less than any next value - LessThan.new(color_class.new, next_color_class.new). - evaluate.should == true_value + expect(LessThan.new(color_class.new, next_color_class.new). + evaluate).to eq(true_value) end end end @@ -120,15 +120,15 @@ it "should evaluate for directions" do dir_classes = Direction.order dir_classes.each_with_index do |dir_class, index| - LessThan.new(dir_class.new, dir_class.new). - evaluate.should == false_value + expect(LessThan.new(dir_class.new, dir_class.new). + evaluate).to eq(false_value) dir_classes.take(index).each do |previous_dir_class| - LessThan.new(dir_class.new, previous_dir_class.new). - evaluate.should == false_value + expect(LessThan.new(dir_class.new, previous_dir_class.new). + evaluate).to eq(false_value) end dir_classes.drop(index+1).each do |next_dir_class| - LessThan.new(dir_class.new, next_dir_class.new). - evaluate.should == true_value + expect(LessThan.new(dir_class.new, next_dir_class.new). + evaluate).to eq(true_value) end end end @@ -138,30 +138,30 @@ describe LessEqual do it "should evaluate for booleans" do - LessEqual.new(false_value, false_value).evaluate.should == true_value - LessEqual.new(false_value, true_value).evaluate.should == true_value - LessEqual.new(true_value, false_value).evaluate.should == false_value - LessEqual.new(true_value, true_value).evaluate.should == true_value + expect(LessEqual.new(false_value, false_value).evaluate).to eq(true_value) + expect(LessEqual.new(false_value, true_value).evaluate).to eq(true_value) + expect(LessEqual.new(true_value, false_value).evaluate).to eq(false_value) + expect(LessEqual.new(true_value, true_value).evaluate).to eq(true_value) end it "should evaluate for numbers" do - LessEqual.new(15.to_gbs_num, 42.to_gbs_num).evaluate.should == true_value - LessEqual.new(42.to_gbs_num, 15.to_gbs_num).evaluate.should == false_value - LessEqual.new(42.to_gbs_num, 42.to_gbs_num).evaluate.should == true_value + expect(LessEqual.new(15.to_gbs_num, 42.to_gbs_num).evaluate).to eq(true_value) + expect(LessEqual.new(42.to_gbs_num, 15.to_gbs_num).evaluate).to eq(false_value) + expect(LessEqual.new(42.to_gbs_num, 42.to_gbs_num).evaluate).to eq(true_value) end it "should evaluate for colors" do color_classes = Color.order color_classes.each_with_index do |color_class, index| - LessEqual.new(color_class.new, color_class.new). - evaluate.should == true_value + expect(LessEqual.new(color_class.new, color_class.new). + evaluate).to eq(true_value) color_classes.take(index).each do |previous_color_class| - LessEqual.new(color_class.new, previous_color_class.new). - evaluate.should == false_value + expect(LessEqual.new(color_class.new, previous_color_class.new). + evaluate).to eq(false_value) end color_classes.drop(index+1).each do |next_color_class| - LessEqual.new(color_class.new, next_color_class.new). - evaluate.should == true_value + expect(LessEqual.new(color_class.new, next_color_class.new). + evaluate).to eq(true_value) end end end @@ -169,15 +169,15 @@ it "should evaluate for directions" do dir_classes = Direction.order dir_classes.each_with_index do |dir_class, index| - LessEqual.new(dir_class.new, dir_class.new). - evaluate.should == true_value + expect(LessEqual.new(dir_class.new, dir_class.new). + evaluate).to eq(true_value) dir_classes.take(index).each do |previous_dir_class| - LessEqual.new(dir_class.new, previous_dir_class.new). - evaluate.should == false_value + expect(LessEqual.new(dir_class.new, previous_dir_class.new). + evaluate).to eq(false_value) end dir_classes.drop(index+1).each do |next_dir_class| - LessEqual.new(dir_class.new, next_dir_class.new). - evaluate.should == true_value + expect(LessEqual.new(dir_class.new, next_dir_class.new). + evaluate).to eq(true_value) end end end @@ -187,30 +187,30 @@ describe GreaterThan do it "should evaluate for booleans" do - GreaterThan.new(false_value, false_value).evaluate.should == false_value - GreaterThan.new(false_value, true_value).evaluate.should == false_value - GreaterThan.new(true_value, false_value).evaluate.should == true_value - GreaterThan.new(true_value, true_value).evaluate.should == false_value + expect(GreaterThan.new(false_value, false_value).evaluate).to eq(false_value) + expect(GreaterThan.new(false_value, true_value).evaluate).to eq(false_value) + expect(GreaterThan.new(true_value, false_value).evaluate).to eq(true_value) + expect(GreaterThan.new(true_value, true_value).evaluate).to eq(false_value) end it "should evaluate for numbers" do - GreaterThan.new(15.to_gbs_num, 42.to_gbs_num).evaluate.should == false_value - GreaterThan.new(42.to_gbs_num, 15.to_gbs_num).evaluate.should == true_value - GreaterThan.new(42.to_gbs_num, 42.to_gbs_num).evaluate.should == false_value + expect(GreaterThan.new(15.to_gbs_num, 42.to_gbs_num).evaluate).to eq(false_value) + expect(GreaterThan.new(42.to_gbs_num, 15.to_gbs_num).evaluate).to eq(true_value) + expect(GreaterThan.new(42.to_gbs_num, 42.to_gbs_num).evaluate).to eq(false_value) end it "should evaluate for colors" do color_classes = Color.order color_classes.each_with_index do |color_class, index| - GreaterThan.new(color_class.new, color_class.new). - evaluate.should == false_value + expect(GreaterThan.new(color_class.new, color_class.new). + evaluate).to eq(false_value) color_classes.take(index).each do |previous_color_class| - GreaterThan.new(color_class.new, previous_color_class.new). - evaluate.should == true_value + expect(GreaterThan.new(color_class.new, previous_color_class.new). + evaluate).to eq(true_value) end color_classes.drop(index+1).each do |next_color_class| - GreaterThan.new(color_class.new, next_color_class.new). - evaluate.should == false_value + expect(GreaterThan.new(color_class.new, next_color_class.new). + evaluate).to eq(false_value) end end end @@ -218,15 +218,15 @@ it "should evaluate for directions" do dir_classes = Direction.order dir_classes.each_with_index do |dir_class, index| - GreaterThan.new(dir_class.new, dir_class.new). - evaluate.should == false_value + expect(GreaterThan.new(dir_class.new, dir_class.new). + evaluate).to eq(false_value) dir_classes.take(index).each do |previous_dir_class| - GreaterThan.new(dir_class.new, previous_dir_class.new). - evaluate.should == true_value + expect(GreaterThan.new(dir_class.new, previous_dir_class.new). + evaluate).to eq(true_value) end dir_classes.drop(index+1).each do |next_dir_class| - GreaterThan.new(dir_class.new, next_dir_class.new). - evaluate.should == false_value + expect(GreaterThan.new(dir_class.new, next_dir_class.new). + evaluate).to eq(false_value) end end end @@ -236,30 +236,30 @@ describe GreaterEqual do it "should evaluate for booleans" do - GreaterEqual.new(false_value, false_value).evaluate.should == true_value - GreaterEqual.new(false_value, true_value).evaluate.should == false_value - GreaterEqual.new(true_value, false_value).evaluate.should == true_value - GreaterEqual.new(true_value, true_value).evaluate.should == true_value + expect(GreaterEqual.new(false_value, false_value).evaluate).to eq(true_value) + expect(GreaterEqual.new(false_value, true_value).evaluate).to eq(false_value) + expect(GreaterEqual.new(true_value, false_value).evaluate).to eq(true_value) + expect(GreaterEqual.new(true_value, true_value).evaluate).to eq(true_value) end it "should evaluate for numbers" do - GreaterEqual.new(15.to_gbs_num, 42.to_gbs_num).evaluate.should == false_value - GreaterEqual.new(42.to_gbs_num, 15.to_gbs_num).evaluate.should == true_value - GreaterEqual.new(42.to_gbs_num, 42.to_gbs_num).evaluate.should == true_value + expect(GreaterEqual.new(15.to_gbs_num, 42.to_gbs_num).evaluate).to eq(false_value) + expect(GreaterEqual.new(42.to_gbs_num, 15.to_gbs_num).evaluate).to eq(true_value) + expect(GreaterEqual.new(42.to_gbs_num, 42.to_gbs_num).evaluate).to eq(true_value) end it "should evaluate for colors" do color_classes = Color.order color_classes.each_with_index do |color_class, index| - GreaterEqual.new(color_class.new, color_class.new). - evaluate.should == true_value + expect(GreaterEqual.new(color_class.new, color_class.new). + evaluate).to eq(true_value) color_classes.take(index).each do |previous_color_class| - GreaterEqual.new(color_class.new, previous_color_class.new). - evaluate.should == true_value + expect(GreaterEqual.new(color_class.new, previous_color_class.new). + evaluate).to eq(true_value) end color_classes.drop(index+1).each do |next_color_class| - GreaterEqual.new(color_class.new, next_color_class.new). - evaluate.should == false_value + expect(GreaterEqual.new(color_class.new, next_color_class.new). + evaluate).to eq(false_value) end end end @@ -267,15 +267,15 @@ it "should evaluate for directions" do dir_classes = Direction.order dir_classes.each_with_index do |dir_class, index| - GreaterEqual.new(dir_class.new, dir_class.new). - evaluate.should == true_value + expect(GreaterEqual.new(dir_class.new, dir_class.new). + evaluate).to eq(true_value) dir_classes.take(index).each do |previous_dir_class| - GreaterEqual.new(dir_class.new, previous_dir_class.new). - evaluate.should == true_value + expect(GreaterEqual.new(dir_class.new, previous_dir_class.new). + evaluate).to eq(true_value) end dir_classes.drop(index+1).each do |next_dir_class| - GreaterEqual.new(dir_class.new, next_dir_class.new). - evaluate.should == false_value + expect(GreaterEqual.new(dir_class.new, next_dir_class.new). + evaluate).to eq(false_value) end end end diff --git a/spec/lang/expressions/primitive_functions_spec.rb b/spec/lang/expressions/primitive_functions_spec.rb index 859882c..f97310c 100644 --- a/spec/lang/expressions/primitive_functions_spec.rb +++ b/spec/lang/expressions/primitive_functions_spec.rb @@ -7,12 +7,12 @@ describe "nroBolitas() function" do it "should evaluates correctly in a clean context" do - NroBolitas.new(black).evaluate(context).should == 0.to_gbs_num + expect(NroBolitas.new(black).evaluate(context)).to eq(0.to_gbs_num) end it "should evaluate correctly in a context with some data" do 5.times { context.head.put black } - NroBolitas.new(black).evaluate(context).should == 5.to_gbs_num + expect(NroBolitas.new(black).evaluate(context)).to eq(5.to_gbs_num) end end @@ -20,12 +20,12 @@ describe "hayBolitas() function" do it "should evaluate correctly in a clean context" do - HayBolitas.new(black).evaluate(context).should == false.to_gbs_bool + expect(HayBolitas.new(black).evaluate(context)).to eq(false.to_gbs_bool) end it "should evaluate correctly in a context with some data" do context.head.put black - HayBolitas.new(black).evaluate(context).should == true.to_gbs_bool + expect(HayBolitas.new(black).evaluate(context)).to eq(true.to_gbs_bool) end end @@ -33,12 +33,12 @@ describe "puedeMover() function" do it "should evaluate correctly in a clean context" do - PuedeMover.new(west).evaluate(context).should == false.to_gbs_bool + expect(PuedeMover.new(west).evaluate(context)).to eq(false.to_gbs_bool) end it "should evaluate correctly in a modified context" do context.head.move(Este.new) - PuedeMover.new(west).evaluate(context).should == true.to_gbs_bool + expect(PuedeMover.new(west).evaluate(context)).to eq(true.to_gbs_bool) end end @@ -46,26 +46,26 @@ describe "siguiente() function" do it "should evaluate correctly for numbers" do - Siguiente.new(15.to_gbs_num).evaluate.should == 16.to_gbs_num + expect(Siguiente.new(15.to_gbs_num).evaluate).to eq(16.to_gbs_num) end it "should evaluate correctly for colors" do - Siguiente.new(Azul.new).evaluate.should == Negro.new - Siguiente.new(Negro.new).evaluate.should == Rojo.new - Siguiente.new(Rojo.new).evaluate.should == Verde.new - Siguiente.new(Verde.new).evaluate.should == Azul.new + expect(Siguiente.new(Azul.new).evaluate).to eq(Negro.new) + expect(Siguiente.new(Negro.new).evaluate).to eq(Rojo.new) + expect(Siguiente.new(Rojo.new).evaluate).to eq(Verde.new) + expect(Siguiente.new(Verde.new).evaluate).to eq(Azul.new) end it "should evaluate correctly for directions" do - Siguiente.new(Norte.new).evaluate.should == Este.new - Siguiente.new(Este.new).evaluate.should == Sur.new - Siguiente.new(Sur.new).evaluate.should == Oeste.new - Siguiente.new(Oeste.new).evaluate.should == Norte.new + expect(Siguiente.new(Norte.new).evaluate).to eq(Este.new) + expect(Siguiente.new(Este.new).evaluate).to eq(Sur.new) + expect(Siguiente.new(Sur.new).evaluate).to eq(Oeste.new) + expect(Siguiente.new(Oeste.new).evaluate).to eq(Norte.new) end it "should evaluate correctly for booleans" do - Siguiente.new(True.new).evaluate.should == False.new - Siguiente.new(False.new).evaluate.should == True.new + expect(Siguiente.new(True.new).evaluate).to eq(False.new) + expect(Siguiente.new(False.new).evaluate).to eq(True.new) end end @@ -73,26 +73,26 @@ describe "previo() function" do it "should evaluate correctly for numbers" do - Previo.new(43.to_gbs_num).evaluate.should == 42.to_gbs_num + expect(Previo.new(43.to_gbs_num).evaluate).to eq(42.to_gbs_num) end it "should evaluate correctly for colors" do - Previo.new(Azul.new).evaluate.should == Verde.new - Previo.new(Negro.new).evaluate.should == Azul.new - Previo.new(Rojo.new).evaluate.should == Negro.new - Previo.new(Verde.new).evaluate.should == Rojo.new + expect(Previo.new(Azul.new).evaluate).to eq(Verde.new) + expect(Previo.new(Negro.new).evaluate).to eq(Azul.new) + expect(Previo.new(Rojo.new).evaluate).to eq(Negro.new) + expect(Previo.new(Verde.new).evaluate).to eq(Rojo.new) end it "should evaluate correctly for directions" do - Previo.new(Norte.new).evaluate.should == Oeste.new - Previo.new(Este.new).evaluate.should == Norte.new - Previo.new(Sur.new).evaluate.should == Este.new - Previo.new(Oeste.new).evaluate.should == Sur.new + expect(Previo.new(Norte.new).evaluate).to eq(Oeste.new) + expect(Previo.new(Este.new).evaluate).to eq(Norte.new) + expect(Previo.new(Sur.new).evaluate).to eq(Este.new) + expect(Previo.new(Oeste.new).evaluate).to eq(Sur.new) end it "should evaluate correctly for booleans" do - Previo.new(True.new).evaluate.should == False.new - Previo.new(False.new).evaluate.should == True.new + expect(Previo.new(True.new).evaluate).to eq(False.new) + expect(Previo.new(False.new).evaluate).to eq(True.new) end end @@ -100,20 +100,20 @@ describe "opuesto() function" do it "should evaluate correctly for numbers" do - Opuesto.new(23.to_gbs_num).evaluate.should == -23.to_gbs_num - Opuesto.new(-42.to_gbs_num).evaluate.should == 42.to_gbs_num + expect(Opuesto.new(23.to_gbs_num).evaluate).to eq(-23.to_gbs_num) + expect(Opuesto.new(-42.to_gbs_num).evaluate).to eq(42.to_gbs_num) end it "should evaluate correctly for directions" do - Opuesto.new(Norte.new).evaluate.should == Sur.new - Opuesto.new(Este.new).evaluate.should == Oeste.new - Opuesto.new(Sur.new).evaluate.should == Norte.new - Opuesto.new(Oeste.new).evaluate.should == Este.new + expect(Opuesto.new(Norte.new).evaluate).to eq(Sur.new) + expect(Opuesto.new(Este.new).evaluate).to eq(Oeste.new) + expect(Opuesto.new(Sur.new).evaluate).to eq(Norte.new) + expect(Opuesto.new(Oeste.new).evaluate).to eq(Este.new) end it "should evaluate correctly for booleans" do - Opuesto.new(True.new).evaluate.should == False.new - Opuesto.new(False.new).evaluate.should == True.new + expect(Opuesto.new(True.new).evaluate).to eq(False.new) + expect(Opuesto.new(False.new).evaluate).to eq(True.new) end it "should fail when evaluating for colors" do diff --git a/spec/lang/expressions/type_bound_functions_spec.rb b/spec/lang/expressions/type_bound_functions_spec.rb index 2b8b534..f97dfd6 100644 --- a/spec/lang/expressions/type_bound_functions_spec.rb +++ b/spec/lang/expressions/type_bound_functions_spec.rb @@ -3,11 +3,11 @@ describe "boolean" do it "should evaluate minBool() to False" do - MinBool.new.evaluate.should == False.new + expect(MinBool.new.evaluate).to eq(False.new) end it "should evaluate maxBool() to True" do - MaxBool.new.evaluate.should == True.new + expect(MaxBool.new.evaluate).to eq(True.new) end end @@ -15,11 +15,11 @@ describe "colors" do it "should evaluate minColor() to Azul" do - MinColor.new.evaluate.should == Azul.new + expect(MinColor.new.evaluate).to eq(Azul.new) end it "should evaluate maxColor() to Verde" do - MaxColor.new.evaluate.should == Verde.new + expect(MaxColor.new.evaluate).to eq(Verde.new) end end @@ -27,11 +27,11 @@ describe "directions" do it "should evaluate minDir() to Norte" do - MinDir.new.evaluate.should == Norte.new + expect(MinDir.new.evaluate).to eq(Norte.new) end it "should evaluate maxDir() to Oeste" do - MaxDir.new.evaluate.should == Oeste.new + expect(MaxDir.new.evaluate).to eq(Oeste.new) end end diff --git a/spec/lang/expressions/var_name_spec.rb b/spec/lang/expressions/var_name_spec.rb index 3534095..ccbb1c4 100644 --- a/spec/lang/expressions/var_name_spec.rb +++ b/spec/lang/expressions/var_name_spec.rb @@ -5,7 +5,7 @@ it "should return the associated value if it was defined in the context" do context.set var_name, 42.to_gbs_num - var_name.evaluate(context).should == 42.to_gbs_num + expect(var_name.evaluate(context)).to eq(42.to_gbs_num) end it "should raise an error if there is no definition in context" do diff --git a/spec/lang/literals/booleans_spec.rb b/spec/lang/literals/booleans_spec.rb index 04d0cde..46b84be 100644 --- a/spec/lang/literals/booleans_spec.rb +++ b/spec/lang/literals/booleans_spec.rb @@ -2,12 +2,12 @@ it "should evaluate true to self" do bool = True.new - bool.evaluate.should == bool + expect(bool.evaluate).to eq(bool) end it "should evaluate false to self" do bool = False.new - bool.evaluate.should == bool + expect(bool.evaluate).to eq(bool) end end \ No newline at end of file diff --git a/spec/lang/literals/colors_spec.rb b/spec/lang/literals/colors_spec.rb index a29bcb6..f14075d 100644 --- a/spec/lang/literals/colors_spec.rb +++ b/spec/lang/literals/colors_spec.rb @@ -3,11 +3,11 @@ let(:all) { [Azul.new, Negro.new, Rojo.new, Verde.new] } it "should evaluate any color to self" do - all.each { |color| color.evaluate.should == color } + all.each { |color| expect(color.evaluate).to eq(color) } end it "should give the string representation" do - all.map(&:to_s).should == ['Azul', 'Negro', 'Rojo', 'Verde'] + expect(all.map(&:to_s)).to eq(['Azul', 'Negro', 'Rojo', 'Verde']) end end \ No newline at end of file diff --git a/spec/lang/literals/directions_spec.rb b/spec/lang/literals/directions_spec.rb index 763ec37..b4190f2 100644 --- a/spec/lang/literals/directions_spec.rb +++ b/spec/lang/literals/directions_spec.rb @@ -3,17 +3,17 @@ let(:all) { [Norte.new, Sur.new, Este.new, Oeste.new] } it "should evaluate any direction to self" do - all.each { |dir| dir.evaluate.should == dir } + all.each { |dir| expect(dir.evaluate).to eq(dir) } end it "should return the string representation" do - all.map(&:to_s).should == ['Norte', 'Sur', 'Este', 'Oeste'] + expect(all.map(&:to_s)).to eq(['Norte', 'Sur', 'Este', 'Oeste']) end describe Norte do it "should return Sur as opposite direction" do - Norte.new.opposite.should == Sur.new + expect(Norte.new.opposite).to eq(Sur.new) end end @@ -21,7 +21,7 @@ describe Este do it "should return Oeste as opposite direction" do - Este.new.opposite.should == Oeste.new + expect(Este.new.opposite).to eq(Oeste.new) end end @@ -29,7 +29,7 @@ describe Sur do it "should return Norte as opposite direction" do - Sur.new.opposite.should == Norte.new + expect(Sur.new.opposite).to eq(Norte.new) end end @@ -37,7 +37,7 @@ describe Oeste do it "should return Este as opposite direction" do - Oeste.new.opposite.should == Este.new + expect(Oeste.new.opposite).to eq(Este.new) end end diff --git a/spec/lang/literals/numbers_spec.rb b/spec/lang/literals/numbers_spec.rb index f528456..1d1b8ed 100644 --- a/spec/lang/literals/numbers_spec.rb +++ b/spec/lang/literals/numbers_spec.rb @@ -2,7 +2,7 @@ it "should evaluate to self" do num = 42.to_gbs_num - num.evaluate.should == num + expect(num.evaluate).to eq(num) end end \ No newline at end of file diff --git a/spec/parser/arithmetic_expressions_spec.rb b/spec/parser/arithmetic_expressions_spec.rb index 025e9ab..5fd9bc2 100644 --- a/spec/parser/arithmetic_expressions_spec.rb +++ b/spec/parser/arithmetic_expressions_spec.rb @@ -10,29 +10,29 @@ it "should parse a + expression" do sum = Add.new a, b - 'a+b'.should be_parsed_as(:expression).and_return(sum) - 'a + b'.should be_parsed_as(:expression).and_return(sum) + expect('a+b').to be_parsed_as(:expression).and_return(sum) + expect('a + b').to be_parsed_as(:expression).and_return(sum) end it "should parse a nested + expression, associating to left" do sum_ab = Add.new a, b total = Add.new sum_ab, c - 'a + b + c'.should be_parsed_as(:expression).and_return(total) + expect('a + b + c').to be_parsed_as(:expression).and_return(total) end it "should parse a - expression" do sub = Sub.new a, b - 'a-b'.should be_parsed_as(:expression).and_return(sub) - 'a - b'.should be_parsed_as(:expression).and_return(sub) + expect('a-b').to be_parsed_as(:expression).and_return(sub) + expect('a - b').to be_parsed_as(:expression).and_return(sub) end it "should parse a nested expression with + and -, associating to left" do sum_ab = Add.new a, b total = Sub.new sum_ab, c - 'a + b - c'.should be_parsed_as(:expression).and_return(total) + expect('a + b - c').to be_parsed_as(:expression).and_return(total) end end @@ -42,36 +42,36 @@ it "should parse a * expression" do mul = Mul.new a, b - 'a*b'.should be_parsed_as(:expression).and_return(mul) - 'a * b'.should be_parsed_as(:expression).and_return(mul) + expect('a*b').to be_parsed_as(:expression).and_return(mul) + expect('a * b').to be_parsed_as(:expression).and_return(mul) end it "should parse a nested * expression" do mul_ab = Mul.new a, b total = Mul.new mul_ab, c - 'a * b * c'.should be_parsed_as(:expression).and_return(total) + expect('a * b * c').to be_parsed_as(:expression).and_return(total) end it "should parse a div expression" do div = Div.new a, b - 'a div b'.should be_parsed_as(:expression).and_return(div) - 'a div b'.should be_parsed_as(:expression).and_return(div) + expect('a div b').to be_parsed_as(:expression).and_return(div) + expect('a div b').to be_parsed_as(:expression).and_return(div) end it "should parse a mod expression" do mod = Mod.new a, b - 'a mod b'.should be_parsed_as(:expression).and_return(mod) - 'a mod b'.should be_parsed_as(:expression).and_return(mod) + expect('a mod b').to be_parsed_as(:expression).and_return(mod) + expect('a mod b').to be_parsed_as(:expression).and_return(mod) end it "should parse a power expression" do pow = Pow.new a, b - 'a^b'.should be_parsed_as(:expression).and_return(pow) - 'a ^ b'.should be_parsed_as(:expression).and_return(pow) + expect('a^b').to be_parsed_as(:expression).and_return(pow) + expect('a ^ b').to be_parsed_as(:expression).and_return(pow) end it "should parse a nested power expression, associating left" do @@ -79,7 +79,7 @@ pow_abc = Pow.new pow_ab, c pow_abcd = Pow.new pow_abc, d - 'a ^ b ^ c ^ d'.should be_parsed_as(:expression).and_return(pow_abcd) + expect('a ^ b ^ c ^ d').to be_parsed_as(:expression).and_return(pow_abcd) end end @@ -91,7 +91,7 @@ sub = Sub.new a, mul add = Add.new sub, d - 'a - b * c + d'.should be_parsed_as(:expression).and_return(add) + expect('a - b * c + d').to be_parsed_as(:expression).and_return(add) end it "should parse using precedence of * over div and mod" do @@ -100,8 +100,8 @@ inner_mul = Mul.new div, mod outer_mul = Mul.new inner_mul, d - 'a div b * a mod c * d'. - should be_parsed_as(:expression).and_return(outer_mul) + expect('a div b * a mod c * d'). + to be_parsed_as(:expression).and_return(outer_mul) end it "should parse using precedence of div and mod over ^" do @@ -109,7 +109,7 @@ pow_cd = Pow.new c, d div = Div.new pow_ab, pow_cd - 'a^b div c^d'.should be_parsed_as(:expression).and_return(div) + expect('a^b div c^d').to be_parsed_as(:expression).and_return(div) end it "should parse an expression with all kind of operators" do @@ -120,8 +120,8 @@ add = Add.new mod, mul sub = Sub.new add, c - 'a mod b ^ c + a * d div b - c'. - should be_parsed_as(:expression).and_return(sub) + expect('a mod b ^ c + a * d div b - c'). + to be_parsed_as(:expression).and_return(sub) end end diff --git a/spec/parser/assignments_spec.rb b/spec/parser/assignments_spec.rb index d06f9ae..7d5da64 100644 --- a/spec/parser/assignments_spec.rb +++ b/spec/parser/assignments_spec.rb @@ -5,10 +5,10 @@ it "should parse a valid assignment with a simple expression" do assignment = SingleAssignment.new VarName.new('myDir'), Norte.new - 'myDir:=Norte'. - should be_parsed_as(:command).and_return(assignment) - 'myDir := Norte'. - should be_parsed_as(:command).and_return(assignment) + expect('myDir:=Norte'). + to be_parsed_as(:command).and_return(assignment) + expect('myDir := Norte'). + to be_parsed_as(:command).and_return(assignment) end it "should parse a valid assignment with a complex expression" do @@ -16,16 +16,16 @@ exp = Or.new False.new, ParenthesesExpr.new(And.new(a, b)) assignment = SingleAssignment.new VarName.new('myVar'), exp - 'myVar := False || (a && b)'. - should be_parsed_as(:command).and_return(assignment) + expect('myVar := False || (a && b)'). + to be_parsed_as(:command).and_return(assignment) end it "should not parse with an invalid var name" do - 'MyWrongVar := a'.should be_parsed_as(:command).and_fail + expect('MyWrongVar := a').to be_parsed_as(:command).and_fail end it "should not parse with a command on the right side" do - 'myVar := Skip'.should be_parsed_as(:command).and_fail + expect('myVar := Skip').to be_parsed_as(:command).and_fail end end diff --git a/spec/parser/boolean_expressions_spec.rb b/spec/parser/boolean_expressions_spec.rb index e8fee8a..5c3343f 100644 --- a/spec/parser/boolean_expressions_spec.rb +++ b/spec/parser/boolean_expressions_spec.rb @@ -10,43 +10,43 @@ it "should parse an expression with ==" do eq = Equal.new a, b - 'a==b'.should be_parsed_as(:expression).and_return(eq) - 'a == b'.should be_parsed_as(:expression).and_return(eq) + expect('a==b').to be_parsed_as(:expression).and_return(eq) + expect('a == b').to be_parsed_as(:expression).and_return(eq) end it "should parse an expression with /=" do not_eq = NotEqual.new a, b - 'a/=b'.should be_parsed_as(:expression).and_return(not_eq) - 'a /= b'.should be_parsed_as(:expression).and_return(not_eq) + expect('a/=b').to be_parsed_as(:expression).and_return(not_eq) + expect('a /= b').to be_parsed_as(:expression).and_return(not_eq) end it "should parse an expression with <" do lt = LessThan.new a, b - 'a=" do ge = GreaterEqual.new a, b - 'a>=b'.should be_parsed_as(:expression).and_return(ge) - 'a >= b'.should be_parsed_as(:expression).and_return(ge) + expect('a>=b').to be_parsed_as(:expression).and_return(ge) + expect('a >= b').to be_parsed_as(:expression).and_return(ge) end it "should parse an expression with >" do gt = GreaterThan.new a, b - 'a>b'.should be_parsed_as(:expression).and_return(gt) - 'a > b'.should be_parsed_as(:expression).and_return(gt) + expect('a>b').to be_parsed_as(:expression).and_return(gt) + expect('a > b').to be_parsed_as(:expression).and_return(gt) end end @@ -57,21 +57,21 @@ exp = Equal.new a, b not_exp = Not.new exp - 'not a == b'.should be_parsed_as(:expression).and_return(not_exp) + expect('not a == b').to be_parsed_as(:expression).and_return(not_exp) end it "should parse an And expression" do exp = And.new a, b - 'a&&b'.should be_parsed_as(:expression).and_return(exp) - 'a && b'.should be_parsed_as(:expression).and_return(exp) + expect('a&&b').to be_parsed_as(:expression).and_return(exp) + expect('a && b').to be_parsed_as(:expression).and_return(exp) end it "should parse an Or expression" do exp = Or.new a, b - 'a||b'.should be_parsed_as(:expression).and_return(exp) - 'a || b'.should be_parsed_as(:expression).and_return(exp) + expect('a||b').to be_parsed_as(:expression).and_return(exp) + expect('a || b').to be_parsed_as(:expression).and_return(exp) end describe "nested" do @@ -80,28 +80,28 @@ inner_or = Or.new b, c outer_or = Or.new a, inner_or - 'a || b || c'.should be_parsed_as(:expression).and_return(outer_or) + expect('a || b || c').to be_parsed_as(:expression).and_return(outer_or) end it "should parse a nested && expression, associating right" do inner_and = And.new b, c outer_and = And.new a, inner_and - 'a && b && c'.should be_parsed_as(:expression).and_return(outer_and) + expect('a && b && c').to be_parsed_as(:expression).and_return(outer_and) end it "|| should take precedence over &&, left" do bc_and = And.new b, c abc_or = Or.new a, bc_and - 'a || b && c'.should be_parsed_as(:expression).and_return(abc_or) + expect('a || b && c').to be_parsed_as(:expression).and_return(abc_or) end it "|| should take precedence over &&, right" do ab_and = And.new a, b abc_or = Or.new ab_and, c - 'a && b || c'.should be_parsed_as(:expression).and_return(abc_or) + expect('a && b || c').to be_parsed_as(:expression).and_return(abc_or) end end diff --git a/spec/parser/command_block_spec.rb b/spec/parser/command_block_spec.rb index a284f31..a3b2d64 100644 --- a/spec/parser/command_block_spec.rb +++ b/spec/parser/command_block_spec.rb @@ -3,13 +3,13 @@ it "should parse an empty block" do cmd_block = CmdBlock.empty - '{}'.should be_parsed_as(:command).and_return(cmd_block) - '{ }'.should be_parsed_as(:command).and_return(cmd_block) + expect('{}').to be_parsed_as(:command).and_return(cmd_block) + expect('{ }').to be_parsed_as(:command).and_return(cmd_block) end it "should parse a block with one simple cmd" do cmd_block = CmdBlock.new [Skip.new] - '{ Skip }'.should be_parsed_as(:command).and_return(cmd_block) + expect('{ Skip }').to be_parsed_as(:command).and_return(cmd_block) end it "should parse a block with many simple commands" do @@ -18,11 +18,11 @@ third = Mover.new Oeste.new cmd_block = CmdBlock.new [first, second, third] - '{ + expect('{ Poner(Verde) BOOM("error") Mover(Oeste) - }'.should be_parsed_as(:command).and_return(cmd_block) + }').to be_parsed_as(:command).and_return(cmd_block) end it "should allow ; between commands" do @@ -31,9 +31,9 @@ third = Mover.new Oeste.new cmd_block = CmdBlock.new [first, second, third] - '{Poner(Verde); BOOM("error"); + expect('{Poner(Verde); BOOM("error"); Mover(Oeste); - }'.should be_parsed_as(:command).and_return(cmd_block) + }').to be_parsed_as(:command).and_return(cmd_block) end it "should parse a block with simple and complex commands" do @@ -41,10 +41,10 @@ second = IfCmd.new True.new, CmdBlock.empty cmd_block = CmdBlock.new [first, second] - '{ + expect('{ Proc() if (True) {} - }'.should be_parsed_as(:command).and_return(cmd_block) + }').to be_parsed_as(:command).and_return(cmd_block) end end diff --git a/spec/parser/data_types_spec.rb b/spec/parser/data_types_spec.rb index 97fac1b..857940a 100644 --- a/spec/parser/data_types_spec.rb +++ b/spec/parser/data_types_spec.rb @@ -3,11 +3,11 @@ describe "numbers" do it "should parse a positive number" do - '42'.should be_parsed_as(:expression).and_return(42.to_gbs_num) + expect('42').to be_parsed_as(:expression).and_return(42.to_gbs_num) end it "should parse a negative number" do - '-42'.should be_parsed_as(:expression).and_return(-42.to_gbs_num) + expect('-42').to be_parsed_as(:expression).and_return(-42.to_gbs_num) end end @@ -15,11 +15,11 @@ describe "booleans" do it "should parse a true boolean" do - 'True'.should be_parsed_as(:expression).and_return(True.new) + expect('True').to be_parsed_as(:expression).and_return(True.new) end it "should parse a false boolean" do - 'False'.should be_parsed_as(:expression).and_return(False.new) + expect('False').to be_parsed_as(:expression).and_return(False.new) end end @@ -27,19 +27,19 @@ describe "colors" do it "should parse the 'Azul' color" do - 'Azul'.should be_parsed_as(:expression).and_return(Azul.new) + expect('Azul').to be_parsed_as(:expression).and_return(Azul.new) end it "should parse the 'Negro' color" do - 'Negro'.should be_parsed_as(:expression).and_return(Negro.new) + expect('Negro').to be_parsed_as(:expression).and_return(Negro.new) end it "should parse the 'Rojo' color" do - 'Rojo'.should be_parsed_as(:expression).and_return(Rojo.new) + expect('Rojo').to be_parsed_as(:expression).and_return(Rojo.new) end it "should parse the 'Verde' color" do - 'Verde'.should be_parsed_as(:expression).and_return(Verde.new) + expect('Verde').to be_parsed_as(:expression).and_return(Verde.new) end end @@ -47,19 +47,19 @@ describe "directions" do it "should parse the 'Norte' direction" do - 'Norte'.should be_parsed_as(:expression).and_return(Norte.new) + expect('Norte').to be_parsed_as(:expression).and_return(Norte.new) end it "should parse the 'Este' direction" do - 'Este'.should be_parsed_as(:expression).and_return(Este.new) + expect('Este').to be_parsed_as(:expression).and_return(Este.new) end it "should parse the 'Sur' direction" do - 'Sur'.should be_parsed_as(:expression).and_return(Sur.new) + expect('Sur').to be_parsed_as(:expression).and_return(Sur.new) end it "should parse the 'Oeste' direction" do - 'Oeste'.should be_parsed_as(:expression).and_return(Oeste.new) + expect('Oeste').to be_parsed_as(:expression).and_return(Oeste.new) end end diff --git a/spec/parser/function_calls_spec.rb b/spec/parser/function_calls_spec.rb index 9f231d4..7daac85 100644 --- a/spec/parser/function_calls_spec.rb +++ b/spec/parser/function_calls_spec.rb @@ -2,16 +2,16 @@ it "should parse a function call without args" do expected = FunctionCall.new 'f1' - 'f1()'.should be_parsed_as(:expression).and_return(expected) + expect('f1()').to be_parsed_as(:expression).and_return(expected) end it "should not parse a function call without a valid identifier" do - 'F1()'.should be_parsed_as(:expression).and_fail + expect('F1()').to be_parsed_as(:expression).and_fail end it "should parse a function call with one arg" do expected = FunctionCall.new 'func1', [Verde.new] - 'func1(Verde)'.should be_parsed_as(:expression).and_return(expected) + expect('func1(Verde)').to be_parsed_as(:expression).and_return(expected) end it "should parse a function with many args" do @@ -20,8 +20,8 @@ third_arg = Norte.new expected = FunctionCall.new 'func1', [first_arg, second_arg, third_arg] - 'func1(42, nroBolitas(Verde), Norte)'. - should be_parsed_as(:expression).and_return(expected) + expect('func1(42, nroBolitas(Verde), Norte)'). + to be_parsed_as(:expression).and_return(expected) end it "should parse a complex function call" do @@ -30,8 +30,8 @@ num_expr = Mul.new 5.to_gbs_num, paren_expr func2_call = FunctionCall.new 'func2', [Verde.new, Opuesto.new(Norte.new)] func1_call = FunctionCall.new 'func1', [or_expr, num_expr, func2_call] - 'func1(a || b, 5*(10 div c), func2(Verde, opuesto(Norte)))'. - should be_parsed_as(:expression).and_return(func1_call) + expect('func1(a || b, 5*(10 div c), func2(Verde, opuesto(Norte)))'). + to be_parsed_as(:expression).and_return(func1_call) end end \ No newline at end of file diff --git a/spec/parser/function_definitions_spec.rb b/spec/parser/function_definitions_spec.rb index a366447..1a06a9d 100644 --- a/spec/parser/function_definitions_spec.rb +++ b/spec/parser/function_definitions_spec.rb @@ -6,8 +6,8 @@ func_def = Function.new 'just42', args, CmdBlock.new([]), func_return - 'function just42() { return (42) }'. - should be_parsed_as(:definition).and_return(func_def) + expect('function just42() { return (42) }'). + to be_parsed_as(:definition).and_return(func_def) end it "should parse a function with some args" do @@ -19,9 +19,9 @@ return_st = ReturnFromFunction.new [Verde.new, PuedeMover.new(Norte.new)] func_def = Function.new 'myCoolFunction', args, CmdBlock.new([]), return_st - 'function myCoolFunction (firstArg, secondArg, thirdArg) { + expect('function myCoolFunction (firstArg, secondArg, thirdArg) { return (Verde, puedeMover(Norte)) -}'.should be_parsed_as(:definition).and_return(func_def) +}').to be_parsed_as(:definition).and_return(func_def) end it "should parse a function with some statements" do @@ -30,21 +30,21 @@ return_st = ReturnFromFunction.new [True.new] func_def = Function.new 'myFunc', args, body, return_st - 'function myFunc(arg) + expect('function myFunc(arg) { Poner(Verde) return (True) -}'.should be_parsed_as(:definition).and_return(func_def) +}').to be_parsed_as(:definition).and_return(func_def) end it "should not parse a function without a valid identifier" do - 'function MyWrongFunc() { return(True) }'. - should be_parsed_as(:definition).and_fail + expect('function MyWrongFunc() { return(True) }'). + to be_parsed_as(:definition).and_fail end it "should not parse a function without a return statement" do - 'function myFuncWithoutReturn() { }'. - should be_parsed_as(:definition).and_fail + expect('function myFuncWithoutReturn() { }'). + to be_parsed_as(:definition).and_fail end end \ No newline at end of file diff --git a/spec/parser/gobstones_program_spec.rb b/spec/parser/gobstones_program_spec.rb index cbe5b46..5e53fcf 100644 --- a/spec/parser/gobstones_program_spec.rb +++ b/spec/parser/gobstones_program_spec.rb @@ -4,7 +4,7 @@ main_def = Main.new CmdBlock.new([]), NoReturnStatement.new program = Program.new [], main_def - 'procedure Main(){}'.should be_parsed_as(:program).and_return(program) + expect('procedure Main(){}').to be_parsed_as(:program).and_return(program) end it "should parse a program with Main and procedures" do @@ -20,7 +20,7 @@ procedure Main() {} GBS - gbs_code.should be_parsed_as(:program).and_return(program) + expect(gbs_code).to be_parsed_as(:program).and_return(program) end it "should parse a program with Main, procedures and functions" do @@ -38,18 +38,18 @@ procedure Main() {} GBS - gbs_code.should be_parsed_as(:program).and_return(program) + expect(gbs_code).to be_parsed_as(:program).and_return(program) end it "should not parse a program without a Main definition" do - 'procedure Procedure1(){} - procedure Procedure2() {}'.should be_parsed_as(:program).and_fail + 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 - 'procedure Procedure1() {} + expect('procedure Procedure1() {} procedure Main() {} - procedure Procedure2() {}'.should be_parsed_as(:program).and_fail + procedure Procedure2() {}').to be_parsed_as(:program).and_fail end end \ No newline at end of file diff --git a/spec/parser/if_command_spec.rb b/spec/parser/if_command_spec.rb index 99b0c52..e629d1d 100644 --- a/spec/parser/if_command_spec.rb +++ b/spec/parser/if_command_spec.rb @@ -5,19 +5,19 @@ it "should parse a statement with a simple boolean and an empty block" do if_cmd = IfCmd.new True.new, CmdBlock.empty - 'if (True) {}'.should be_parsed_as(:command).and_return(if_cmd) - 'if (True) { - }'.should be_parsed_as(:command).and_return(if_cmd) - 'if (True) - {}'.should be_parsed_as(:command).and_return(if_cmd) + expect('if (True) {}').to be_parsed_as(:command).and_return(if_cmd) + expect('if (True) { + }').to be_parsed_as(:command).and_return(if_cmd) + expect('if (True) + {}').to be_parsed_as(:command).and_return(if_cmd) end it "should parse a statement with a simple boolean and a block with commands" do cmd_block = CmdBlock.new [Poner.new(Verde.new), Skip.new] if_cmd = IfCmd.new False.new, cmd_block - 'if(False){Poner(Verde); Skip}'. - should be_parsed_as(:command).and_return(if_cmd) + expect('if(False){Poner(Verde); Skip}'). + to be_parsed_as(:command).and_return(if_cmd) end it "should parse a statement with a complex boolean expression" do @@ -25,8 +25,8 @@ exp = Or.new PuedeMover.new(Norte.new), ParenthesesExpr.new(and_expr) if_cmd = IfCmd.new exp, CmdBlock.empty - 'if (puedeMover(Norte) || (a && False)) {}'. - should be_parsed_as(:command).and_return(if_cmd) + expect('if (puedeMover(Norte) || (a && False)) {}'). + to be_parsed_as(:command).and_return(if_cmd) end end @@ -37,8 +37,8 @@ else_block = CmdBlock.new [Mover.new(Norte.new)] if_else_cmd = IfElseCmd.new False.new, CmdBlock.empty, else_block - 'if (False) { } else { Mover(Norte) }'. - should be_parsed_as(:command).and_return(if_else_cmd) + expect('if (False) { } else { Mover(Norte) }'). + to be_parsed_as(:command).and_return(if_else_cmd) end end diff --git a/spec/parser/main_definition_spec.rb b/spec/parser/main_definition_spec.rb index d9c5357..d8b730c 100644 --- a/spec/parser/main_definition_spec.rb +++ b/spec/parser/main_definition_spec.rb @@ -3,16 +3,16 @@ it "should parse a valid Main definition without return nor commands" do main = Main.new CmdBlock.new([]), NoReturnStatement.new - 'procedure Main() {}'.should be_parsed_as(:definition).and_fail - 'procedure Main() {}'.should be_parsed_as(:main).and_return(main) + expect('procedure Main() {}').to be_parsed_as(:definition).and_fail + expect('procedure Main() {}').to be_parsed_as(:main).and_return(main) end it "should parse a valid main procedure with a return of var names" do return_tuple = VarTuple.new [VarName.new('x'), VarName.new('y')] main = Main.new CmdBlock.new([]), ReturnFromMain.new(return_tuple) - 'procedure Main() { return (x, y); }'. - should be_parsed_as(:main).and_return(main) + expect('procedure Main() { return (x, y); }'). + to be_parsed_as(:main).and_return(main) end it "should parse a valid main procedure with commands and return" do @@ -20,23 +20,23 @@ cmd_block = CmdBlock.new [Mover.new(Oeste.new), Skip.new] main = Main.new cmd_block, ReturnFromMain.new(return_tuple) - 'procedure Main() { + expect('procedure Main() { Mover(Oeste) Skip return (x, y) - }'.should be_parsed_as(:main).and_return(main) + }').to be_parsed_as(:main).and_return(main) end it "should not parse a main procedure with an invalid identifier" do - 'procedure NotMain() {}'.should be_parsed_as(:main).and_fail + expect('procedure NotMain() {}').to be_parsed_as(:main).and_fail end it "should not parse a main procedure with a return of expressions" do - 'procedure Main() { return (3+4) }'.should be_parsed_as(:main).and_fail + expect('procedure Main() { return (3+4) }').to be_parsed_as(:main).and_fail end it "should not parse a main procedure with args" do - 'procedure Main(arg1, arg2) {}'.should be_parsed_as(:main).and_fail + expect('procedure Main(arg1, arg2) {}').to be_parsed_as(:main).and_fail end end \ No newline at end of file diff --git a/spec/parser/nested_expressions_spec.rb b/spec/parser/nested_expressions_spec.rb index 5f284a5..268bb17 100644 --- a/spec/parser/nested_expressions_spec.rb +++ b/spec/parser/nested_expressions_spec.rb @@ -1,26 +1,26 @@ describe Gobstones::Parser, "nested expressions" do it "should parse literals between ()" do - '( 42 )'.should be_parsed_as(:expression). + expect('( 42 )').to be_parsed_as(:expression). and_return(ParenthesesExpr.new(42.to_gbs_num)) - '(True )'.should be_parsed_as(:expression). + expect('(True )').to be_parsed_as(:expression). and_return(ParenthesesExpr.new(True.new)) - '(Rojo )'.should be_parsed_as(:expression). + expect('(Rojo )').to be_parsed_as(:expression). and_return(ParenthesesExpr.new(Rojo.new)) - '(Verde)'.should be_parsed_as(:expression). + expect('(Verde)').to be_parsed_as(:expression). and_return(ParenthesesExpr.new(Verde.new)) end it "should parse primitive functions between ()" do puede_mover = ParenthesesExpr.new(PuedeMover.new(Norte.new)) - '(puedeMover(Norte))'. - should be_parsed_as(:expression).and_return(puede_mover) + expect('(puedeMover(Norte))'). + to be_parsed_as(:expression).and_return(puede_mover) end it "should parse nested arithmetic expressions between ()" do paren_expr = ParenthesesExpr.new Add.new(3.to_gbs_num, 5.to_gbs_num) expected = Mul.new paren_expr, 6.to_gbs_num - '(3 + 5) * 6'.should be_parsed_as(:expression).and_return(expected) + expect('(3 + 5) * 6').to be_parsed_as(:expression).and_return(expected) end it "should parse a nested expressions with many ()" do @@ -33,7 +33,7 @@ outer_paren = ParenthesesExpr.new and_expr d = VarName.new 'd' result = And.new outer_paren, d - '(a && (b || c)) && d'.should be_parsed_as(:expression).and_return(result) + expect('(a && (b || c)) && d').to be_parsed_as(:expression).and_return(result) end end \ No newline at end of file diff --git a/spec/parser/primitive_expressions_spec.rb b/spec/parser/primitive_expressions_spec.rb index dceb38d..c2c599e 100644 --- a/spec/parser/primitive_expressions_spec.rb +++ b/spec/parser/primitive_expressions_spec.rb @@ -3,22 +3,22 @@ describe "variable identifiers" do it "should parse valid var names" do - 'v'.should be_parsed_as(:expression).and_return(VarName.new('v')) - 'var1'.should be_parsed_as(:expression).and_return(VarName.new('var1')) - 'a_var'.should be_parsed_as(:expression).and_return(VarName.new('a_var')) - 'vAR'.should be_parsed_as(:expression).and_return(VarName.new('vAR')) + expect('v').to be_parsed_as(:expression).and_return(VarName.new('v')) + expect('var1').to be_parsed_as(:expression).and_return(VarName.new('var1')) + expect('a_var').to be_parsed_as(:expression).and_return(VarName.new('a_var')) + expect('vAR').to be_parsed_as(:expression).and_return(VarName.new('vAR')) end it "should not parse invalid var names" do - '1'.should_not be_parsed_as(:expression).and_return(VarName.new('1')) - '_var'.should be_parsed_as(:expression).and_fail - 'Var'.should be_parsed_as(:expression).and_fail + expect('1').not_to be_parsed_as(:expression).and_return(VarName.new('1')) + expect('_var').to be_parsed_as(:expression).and_fail + expect('Var').to be_parsed_as(:expression).and_fail end it "should not parse reserved words as var names" do literals = %w{True False Rojo Negro Azul Verde Norte Oeste Este Sur} (RESERVED_IDS - literals).each do |id| - id.should be_parsed_as(:expression).and_fail + expect(id).to be_parsed_as(:expression).and_fail end end @@ -27,27 +27,27 @@ describe "type bounds functions" do it "should parse the minBool() function" do - 'minBool()'.should be_parsed_as(:expression).and_return(MinBool.new) + expect('minBool()').to be_parsed_as(:expression).and_return(MinBool.new) end it "should parse the maxBool() function" do - 'maxBool()'.should be_parsed_as(:expression).and_return(MaxBool.new) + expect('maxBool()').to be_parsed_as(:expression).and_return(MaxBool.new) end it "should parse the minColor() function" do - 'minColor()'.should be_parsed_as(:expression).and_return(MinColor.new) + expect('minColor()').to be_parsed_as(:expression).and_return(MinColor.new) end it "should parse the maxColor() function" do - 'maxColor()'.should be_parsed_as(:expression).and_return(MaxColor.new) + expect('maxColor()').to be_parsed_as(:expression).and_return(MaxColor.new) end it "should parse the minDir() function" do - 'minDir()'.should be_parsed_as(:expression).and_return(MinDir.new) + expect('minDir()').to be_parsed_as(:expression).and_return(MinDir.new) end it "should parse the maxDir() function" do - 'maxDir()'.should be_parsed_as(:expression).and_return(MaxDir.new) + expect('maxDir()').to be_parsed_as(:expression).and_return(MaxDir.new) end end @@ -57,22 +57,22 @@ it "should parse the siguiente() function " do arg = VarName.new 'x' func = Siguiente.new arg - 'siguiente(x)'.should be_parsed_as(:expression).and_return(func) - 'siguiente(x )'.should be_parsed_as(:expression).and_return(func) + expect('siguiente(x)').to be_parsed_as(:expression).and_return(func) + expect('siguiente(x )').to be_parsed_as(:expression).and_return(func) end it "should parse the previo() function" do arg = VarName.new 'y' func = Previo.new arg - 'previo(y)'.should be_parsed_as(:expression).and_return(func) - 'previo( y )'.should be_parsed_as(:expression).and_return(func) + expect('previo(y)').to be_parsed_as(:expression).and_return(func) + expect('previo( y )').to be_parsed_as(:expression).and_return(func) end it "should parse the opuesto() function" do arg = VarName.new 'z' func = Opuesto.new arg - 'opuesto(z)'.should be_parsed_as(:expression).and_return(func) - 'opuesto( z )'.should be_parsed_as(:expression).and_return(func) + expect('opuesto(z)').to be_parsed_as(:expression).and_return(func) + expect('opuesto( z )').to be_parsed_as(:expression).and_return(func) end end @@ -82,22 +82,22 @@ it "should parse the nroBolitas(exp) function" do arg = VarName.new 'color' func = NroBolitas.new arg - 'nroBolitas(color)'.should be_parsed_as(:expression).and_return(func) - 'nroBolitas( color )'.should be_parsed_as(:expression).and_return(func) + expect('nroBolitas(color)').to be_parsed_as(:expression).and_return(func) + expect('nroBolitas( color )').to be_parsed_as(:expression).and_return(func) end it "should parse the hayBolitas(exp) function" do arg = VarName.new 'color' func = HayBolitas.new arg - 'hayBolitas(color)'.should be_parsed_as(:expression).and_return(func) - 'hayBolitas( color )'.should be_parsed_as(:expression).and_return(func) + expect('hayBolitas(color)').to be_parsed_as(:expression).and_return(func) + expect('hayBolitas( color )').to be_parsed_as(:expression).and_return(func) end it "should parse the puedeMover(exp) function" do arg = VarName.new 'dir' func = PuedeMover.new arg - 'puedeMover(dir)'.should be_parsed_as(:expression).and_return(func) - 'puedeMover( dir )'.should be_parsed_as(:expression).and_return(func) + expect('puedeMover(dir)').to be_parsed_as(:expression).and_return(func) + expect('puedeMover( dir )').to be_parsed_as(:expression).and_return(func) end end diff --git a/spec/parser/procedure_calls_spec.rb b/spec/parser/procedure_calls_spec.rb index 18dd341..9567fc8 100644 --- a/spec/parser/procedure_calls_spec.rb +++ b/spec/parser/procedure_calls_spec.rb @@ -1,16 +1,16 @@ describe Gobstones::Parser, "procedure calls" do it "should parse a procedure call without args" do - 'P1()'.should be_parsed_as(:command).and_return(ProcedureCall.new('P1')) + expect('P1()').to be_parsed_as(:command).and_return(ProcedureCall.new('P1')) end it "should not parse a procedure call without a valid identifier" do - 'p1()'.should be_parsed_as(:command).and_fail + expect('p1()').to be_parsed_as(:command).and_fail end it "should parse a procedure call with one arg" do expected = ProcedureCall.new 'Proc1', [Verde.new] - 'Proc1(Verde)'.should be_parsed_as(:command).and_return(expected) + expect('Proc1(Verde)').to be_parsed_as(:command).and_return(expected) end it "should parse a procedure with many args" do @@ -19,8 +19,8 @@ third_arg = Norte.new expected = ProcedureCall.new 'Proc1', [first_arg, second_arg, third_arg] - 'Proc1(42, nroBolitas(Verde), Norte)'. - should be_parsed_as(:command).and_return(expected) + expect('Proc1(42, nroBolitas(Verde), Norte)'). + to be_parsed_as(:command).and_return(expected) end it "should parse a complex procedure call" do @@ -29,8 +29,8 @@ num_expr = Mul.new 5.to_gbs_num, paren_expr func_call = FunctionCall.new 'func', [Verde.new, Opuesto.new(Norte.new)] proc_call = ProcedureCall.new 'Proc1', [or_expr, num_expr, func_call] - 'Proc1(a || b, 5*(10 div c), func(Verde, opuesto(Norte)))'. - should be_parsed_as(:command).and_return(proc_call) + expect('Proc1(a || b, 5*(10 div c), func(Verde, opuesto(Norte)))'). + to be_parsed_as(:command).and_return(proc_call) end end \ No newline at end of file diff --git a/spec/parser/procedure_definitions_spec.rb b/spec/parser/procedure_definitions_spec.rb index 295ba4e..0736b31 100644 --- a/spec/parser/procedure_definitions_spec.rb +++ b/spec/parser/procedure_definitions_spec.rb @@ -6,8 +6,8 @@ args = VarTuple.new [] proc_def = Procedure.new 'MyProc', args, body - 'procedure MyProc() {}'. - should be_parsed_as(:definition).and_return(proc_def) + expect('procedure MyProc() {}'). + to be_parsed_as(:definition).and_return(proc_def) end it "should parse an empty procedure with some args" do @@ -17,8 +17,8 @@ args = VarTuple.new [first_arg, second_arg, third_arg] proc_def = Procedure.new 'MyProc', args, body - 'procedure MyProc (firstArg, secondArg, thirdArg) {}'. - should be_parsed_as(:definition).and_return(proc_def) + expect('procedure MyProc (firstArg, secondArg, thirdArg) {}'). + to be_parsed_as(:definition).and_return(proc_def) end it "should parse a procedure with some statements" do @@ -26,14 +26,14 @@ body = CmdBlock.new [Poner.new(Verde.new)] proc_def = Procedure.new 'MyProc', args, body - 'procedure MyProc(arg) + expect('procedure MyProc(arg) { Poner(Verde) -}'.should be_parsed_as(:definition).and_return(proc_def) +}').to be_parsed_as(:definition).and_return(proc_def) end it "should not parse a procedure without a valid identifier" do - 'procedure myWrongProc() {}'.should be_parsed_as(:definition).and_fail + expect('procedure myWrongProc() {}').to be_parsed_as(:definition).and_fail end end \ No newline at end of file diff --git a/spec/parser/repeat_with_command_spec.rb b/spec/parser/repeat_with_command_spec.rb index 0986e79..149323b 100644 --- a/spec/parser/repeat_with_command_spec.rb +++ b/spec/parser/repeat_with_command_spec.rb @@ -6,7 +6,7 @@ cmd_block = CmdBlock.empty rw_cmd = RepeatWithCmd.new var_name, min_range, max_range, cmd_block - 'repeatWith i in 1..10 {}'.should be_parsed_as(:command).and_return(rw_cmd) + expect('repeatWith i in 1..10 {}').to be_parsed_as(:command).and_return(rw_cmd) end it "should parse an statement with any expressions in the range" do @@ -15,9 +15,9 @@ cmd_block = CmdBlock.new [Poner.new(Verde.new)] rw_cmd = RepeatWithCmd.new var_name, min_range, max_range, cmd_block - 'repeatWith myDir in minDir() .. siguiente(Rojo) { + expect('repeatWith myDir in minDir() .. siguiente(Rojo) { Poner(Verde) - }'.should be_parsed_as(:command).and_return(rw_cmd) + }').to be_parsed_as(:command).and_return(rw_cmd) end end \ No newline at end of file diff --git a/spec/parser/simple_commands_spec.rb b/spec/parser/simple_commands_spec.rb index 47cf598..a88d856 100644 --- a/spec/parser/simple_commands_spec.rb +++ b/spec/parser/simple_commands_spec.rb @@ -7,14 +7,14 @@ it "should parse a Skip cmd" do skip_cmd = Skip.new - 'Skip'.should be_parsed_as(:command).and_return(skip_cmd) + expect('Skip').to be_parsed_as(:command).and_return(skip_cmd) end it "should parse a BOOM cmd" do boom_cmd = Boom.new 'the message' - 'BOOM("the message")'.should be_parsed_as(:command).and_return(boom_cmd) - 'BOOM ("the message")'.should be_parsed_as(:command).and_return(boom_cmd) - 'BOOM( "the message" )'.should be_parsed_as(:command).and_return(boom_cmd) + expect('BOOM("the message")').to be_parsed_as(:command).and_return(boom_cmd) + expect('BOOM ("the message")').to be_parsed_as(:command).and_return(boom_cmd) + expect('BOOM( "the message" )').to be_parsed_as(:command).and_return(boom_cmd) end ['Poner', 'Sacar', 'Mover'].each do |command| @@ -23,22 +23,22 @@ it "should be parsed ok with a primitive as argument" do cmd = Kernel.const_get(command).new Verde.new - "#{command}(Verde)".should be_parsed_as(:command).and_return(cmd) - "#{command} (Verde)".should be_parsed_as(:command).and_return(cmd) - "#{command}( Verde )".should be_parsed_as(:command).and_return(cmd) + expect("#{command}(Verde)").to be_parsed_as(:command).and_return(cmd) + expect("#{command} (Verde)").to be_parsed_as(:command).and_return(cmd) + expect("#{command}( Verde )").to be_parsed_as(:command).and_return(cmd) end it "should be parsed ok with a simple expression as argument" do cmd = Kernel.const_get(command).new MinColor.new - "#{command}(minColor())". - should be_parsed_as(:command).and_return(cmd) + expect("#{command}(minColor())"). + to be_parsed_as(:command).and_return(cmd) end it "should be parsed ok with a complex expression as argument" do func_call = FunctionCall.new 'funcCall', [Norte.new, 42.to_gbs_num] cmd = Kernel.const_get(command).new Opuesto.new(func_call) - "#{command}(opuesto(funcCall(Norte, 42)))". - should be_parsed_as(:command).and_return(cmd) + expect("#{command}(opuesto(funcCall(Norte, 42)))"). + to be_parsed_as(:command).and_return(cmd) end end @@ -47,13 +47,13 @@ it "should parse a IrAlOrigen cmd" do ir_al_origen_cmd = IrAlOrigen.new - 'IrAlOrigen()'.should be_parsed_as(:command). + expect('IrAlOrigen()').to be_parsed_as(:command). and_return(ir_al_origen_cmd) end it "should parse a VaciarTablero cmd" do vaciar_tablero_cmd = VaciarTablero.new - 'VaciarTablero()'.should be_parsed_as(:command). + expect('VaciarTablero()').to be_parsed_as(:command). and_return(vaciar_tablero_cmd) end diff --git a/spec/parser/treetop_parser_spec.rb b/spec/parser/treetop_parser_spec.rb index 637eeca..d868cd1 100644 --- a/spec/parser/treetop_parser_spec.rb +++ b/spec/parser/treetop_parser_spec.rb @@ -7,7 +7,7 @@ it "should remove a one-line comment with // characters for a single line" do code_with_comments = 'Poner(Verde) // put a green ball on the board' code_without_comments = @parser.remove_comments_from code_with_comments - code_without_comments.should == 'Poner(Verde) ' + expect(code_without_comments).to eq('Poner(Verde) ') end it "should remove many one-line comments with //" do @@ -17,7 +17,7 @@ // and this is just an entire comment line CODE code_without_comments = @parser.remove_comments_from code_with_comments - code_without_comments.should == <