gobstones 0.0.1.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -3
  3. data/.ruby-version +1 -1
  4. data/.travis.yml +1 -1
  5. data/CHANGELOG +22 -2
  6. data/Gemfile +3 -3
  7. data/Gemfile.lock +32 -27
  8. data/bin/gobstones +1 -1
  9. data/examples/.gitkeep +0 -0
  10. data/gobstones.gemspec +2 -2
  11. data/lib/gobstones/cli/board_template +1 -1
  12. data/lib/gobstones/cli/printer.rb +1 -1
  13. data/lib/gobstones/cli/runner.rb +8 -2
  14. data/lib/gobstones/extensions/all.rb +2 -1
  15. data/lib/gobstones/extensions/boolean.rb +1 -1
  16. data/lib/gobstones/extensions/fixnum.rb +1 -1
  17. data/lib/gobstones/extensions/string.rb +9 -0
  18. data/lib/gobstones/lang/all.rb +1 -1
  19. data/lib/gobstones/lang/commands/all.rb +3 -2
  20. data/lib/gobstones/lang/commands/boom_cmd.rb +6 -3
  21. data/lib/gobstones/lang/commands/command_block.rb +1 -1
  22. data/lib/gobstones/lang/commands/conditional_cmd.rb +5 -1
  23. data/lib/gobstones/lang/commands/ir_al_origen_cmd.rb +1 -1
  24. data/lib/gobstones/lang/commands/mover_cmd.rb +4 -2
  25. data/lib/gobstones/lang/commands/multiple_assignment.rb +35 -0
  26. data/lib/gobstones/lang/commands/poner_cmd.rb +8 -4
  27. data/lib/gobstones/lang/commands/procedure_call.rb +1 -9
  28. data/lib/gobstones/lang/commands/repeat_with_cmd.rb +10 -6
  29. data/lib/gobstones/lang/commands/sacar_cmd.rb +9 -7
  30. data/lib/gobstones/lang/commands/{assignments.rb → single_assignment.rb} +5 -3
  31. data/lib/gobstones/lang/commands/skip_cmd.rb +2 -2
  32. data/lib/gobstones/lang/commands/vaciar_tablero_cmd.rb +1 -1
  33. data/lib/gobstones/lang/commands/while_cmd.rb +1 -1
  34. data/lib/gobstones/lang/definitions/all.rb +1 -1
  35. data/lib/gobstones/lang/definitions/definition.rb +47 -5
  36. data/lib/gobstones/lang/definitions/definition_call.rb +17 -5
  37. data/lib/gobstones/lang/definitions/function.rb +9 -0
  38. data/lib/gobstones/lang/definitions/main.rb +1 -1
  39. data/lib/gobstones/lang/definitions/no_return_statement.rb +7 -3
  40. data/lib/gobstones/lang/definitions/procedure.rb +5 -20
  41. data/lib/gobstones/lang/definitions/return_from_function.rb +12 -2
  42. data/lib/gobstones/lang/definitions/return_from_main.rb +5 -1
  43. data/lib/gobstones/lang/definitions/var_tuple.rb +13 -1
  44. data/lib/gobstones/lang/expressions/all.rb +1 -1
  45. data/lib/gobstones/lang/expressions/arithmetic_expressions.rb +1 -1
  46. data/lib/gobstones/lang/expressions/boolean_expressions.rb +3 -2
  47. data/lib/gobstones/lang/expressions/enclosed_by_parens_expression.rb +17 -0
  48. data/lib/gobstones/lang/expressions/function_call.rb +1 -1
  49. data/lib/gobstones/lang/expressions/one_arg_expression.rb +16 -4
  50. data/lib/gobstones/lang/expressions/primitive_functions.rb +18 -12
  51. data/lib/gobstones/lang/expressions/two_arg_expression.rb +7 -3
  52. data/lib/gobstones/lang/expressions/type_bound_functions.rb +1 -1
  53. data/lib/gobstones/lang/expressions/var_name.rb +9 -3
  54. data/lib/gobstones/lang/literals/all.rb +1 -1
  55. data/lib/gobstones/lang/literals/colors.rb +1 -1
  56. data/lib/gobstones/lang/literals/literal.rb +31 -21
  57. data/lib/gobstones/lang/literals/number.rb +1 -1
  58. data/lib/gobstones/lang/program.rb +13 -4
  59. data/lib/gobstones/modules/equal_by_class.rb +1 -1
  60. data/lib/gobstones/parser/ast/ast.rb +12 -8
  61. data/lib/gobstones/parser/grammar/gobstones.treetop +4 -4
  62. data/lib/gobstones/parser/parse_error.rb +1 -1
  63. data/lib/gobstones/runner/all.rb +1 -2
  64. data/lib/gobstones/runner/board.rb +13 -4
  65. data/lib/gobstones/runner/cell.rb +10 -0
  66. data/lib/gobstones/runner/errors/all.rb +1 -1
  67. data/lib/gobstones/runner/errors/definition_not_found_error.rb +1 -1
  68. data/lib/gobstones/runner/execution_context.rb +66 -16
  69. data/lib/gobstones/runner/head.rb +17 -3
  70. data/spec/gobstones_lang_test_objects.rb +75 -0
  71. data/spec/lang/commands/boom_cmd_spec.rb +3 -3
  72. data/spec/lang/commands/cmd_block_spec.rb +14 -14
  73. data/spec/lang/commands/if_cmd_spec.rb +21 -20
  74. data/spec/lang/commands/ir_al_origen_cmd_spec.rb +3 -3
  75. data/spec/lang/commands/mover_cmd_spec.rb +12 -14
  76. data/spec/lang/commands/multiple_assignment_spec.rb +37 -0
  77. data/spec/lang/commands/poner_cmd_spec.rb +13 -14
  78. data/spec/lang/commands/procedure_call_spec.rb +19 -24
  79. data/spec/lang/commands/procedure_spec.rb +32 -36
  80. data/spec/lang/commands/repeat_with_cmd_spec.rb +39 -20
  81. data/spec/lang/commands/sacar_cmd_spec.rb +17 -16
  82. data/spec/lang/commands/single_assignment_spec.rb +13 -0
  83. data/spec/lang/commands/skip_cmd_spec.rb +2 -2
  84. data/spec/lang/commands/vaciar_tablero_cmd_spec.rb +7 -6
  85. data/spec/lang/commands/while_cmd_spec.rb +21 -15
  86. data/spec/lang/definitions/no_return_statement_spec.rb +10 -0
  87. data/spec/lang/definitions/var_tuple_spec.rb +16 -0
  88. data/spec/lang/expressions/arithmetic_expressions_spec.rb +15 -15
  89. data/spec/lang/expressions/boolean_expressions_spec.rb +35 -25
  90. data/spec/lang/expressions/comparison_expressions_spec.rb +25 -28
  91. data/spec/lang/expressions/enclosed_by_parens_expression_spec.rb +11 -0
  92. data/spec/lang/expressions/function_call_spec.rb +29 -0
  93. data/spec/lang/expressions/primitive_functions_spec.rb +60 -62
  94. data/spec/lang/expressions/type_bound_functions_spec.rb +13 -13
  95. data/spec/lang/expressions/var_name_spec.rb +20 -8
  96. data/spec/lang/literals/booleans_spec.rb +5 -7
  97. data/spec/lang/literals/colors_spec.rb +4 -4
  98. data/spec/lang/literals/directions_spec.rb +12 -12
  99. data/spec/lang/literals/numbers_spec.rb +2 -2
  100. data/spec/matchers/parse_matcher.rb +9 -10
  101. data/spec/parser/arithmetic_expressions_spec.rb +19 -19
  102. data/spec/parser/assignments_spec.rb +24 -10
  103. data/spec/parser/boolean_expressions_spec.rb +18 -18
  104. data/spec/parser/command_block_spec.rb +17 -19
  105. data/spec/parser/data_types_spec.rb +23 -23
  106. data/spec/parser/function_calls_spec.rb +13 -12
  107. data/spec/parser/function_definitions_spec.rb +13 -18
  108. data/spec/parser/gobstones_program_spec.rb +15 -15
  109. data/spec/parser/if_command_spec.rb +13 -12
  110. data/spec/parser/main_definition_spec.rb +12 -12
  111. data/spec/parser/nested_expressions_spec.rb +16 -20
  112. data/spec/parser/primitive_expressions_spec.rb +27 -33
  113. data/spec/parser/procedure_calls_spec.rb +12 -12
  114. data/spec/parser/procedure_definitions_spec.rb +10 -16
  115. data/spec/parser/repeat_with_command_spec.rb +7 -10
  116. data/spec/parser/simple_commands_spec.rb +10 -10
  117. data/spec/parser/treetop_parser_spec.rb +11 -10
  118. data/spec/parser/var_tuple_spec.rb +7 -11
  119. data/spec/parser/while_command_spec.rb +9 -9
  120. data/spec/runner/board_spec.rb +23 -27
  121. data/spec/runner/cell_spec.rb +34 -38
  122. data/spec/runner/execution_context_spec.rb +38 -24
  123. data/spec/runner/head_spec.rb +54 -63
  124. data/spec/spec_helper.rb +4 -1
  125. data/spec/type_checker_spec.rb +13 -13
  126. metadata +33 -18
  127. data/lib/gobstones/lang/expressions/parentheses_expression.rb +0 -13
  128. data/spec/lang/commands/assignments_spec.rb +0 -13
@@ -1,72 +1,68 @@
1
1
  describe Cell do
2
2
 
3
- let(:black) { Negro.new }
4
- let(:blue) { Azul.new }
5
- let(:green) { Verde.new }
6
- let(:red) { Rojo.new }
7
- let(:colors) { [blue, black, red, green] }
3
+ let(:colors) { [azul, negro, rojo, verde] }
8
4
  let(:cell) { Cell.new }
9
5
 
10
- it "should answer that there are no balls of a given color" do
11
- expect(cell.are_there_balls?(blue)).to be_false
12
- expect(cell.are_there_balls?(black)).to be_false
13
- expect(cell.are_there_balls?(red)).to be_false
14
- expect(cell.are_there_balls?(green)).to be_false
6
+ it "answers that there are no balls of a given color" do
7
+ expect(cell.are_there_balls?(azul)).to be false
8
+ expect(cell.are_there_balls?(negro)).to be false
9
+ expect(cell.are_there_balls?(rojo)).to be false
10
+ expect(cell.are_there_balls?(verde)).to be false
15
11
  end
16
12
 
17
- it "should answer that there are balls of a given color when adding some" do
18
- cell.put blue
19
- cell.put red
13
+ it "answers that there are balls of a given color when adding some" do
14
+ cell.put azul
15
+ cell.put rojo
20
16
 
21
- expect(cell.are_there_balls?(blue)).to be_true
22
- expect(cell.are_there_balls?(black)).to be_false
23
- expect(cell.are_there_balls?(red)).to be_true
24
- expect(cell.are_there_balls?(green)).to be_false
17
+ expect(cell.are_there_balls?(azul)).to be true
18
+ expect(cell.are_there_balls?(negro)).to be false
19
+ expect(cell.are_there_balls?(rojo)).to be true
20
+ expect(cell.are_there_balls?(verde)).to be false
25
21
  end
26
22
 
27
- it "should answer the number of balls of a given color" do
28
- 5.times { cell.put green }
23
+ it "answers the number of balls of a given color" do
24
+ 5.times { cell.put verde }
29
25
 
30
- expect(cell.number_of_balls(blue)).to eq(0)
31
- expect(cell.number_of_balls(black)).to eq(0)
32
- expect(cell.number_of_balls(red)).to eq(0)
33
- expect(cell.number_of_balls(green)).to eq(5)
26
+ expect(cell.number_of_balls(azul)).to eq(0)
27
+ expect(cell.number_of_balls(negro)).to eq(0)
28
+ expect(cell.number_of_balls(rojo)).to eq(0)
29
+ expect(cell.number_of_balls(verde)).to eq(5)
34
30
  end
35
31
 
36
- it "should allow to take out some balls" do
37
- 5.times { cell.put blue }
38
- 3.times { cell.take_out blue }
32
+ it "allows to take out some balls" do
33
+ 5.times { cell.put azul }
34
+ 3.times { cell.take_out azul }
39
35
 
40
- expect(cell.are_there_balls?(blue)).to be_true
41
- expect(cell.number_of_balls(blue)).to eq(2)
36
+ expect(cell.are_there_balls?(azul)).to be true
37
+ expect(cell.number_of_balls(azul)).to eq(2)
42
38
  end
43
39
 
44
- it "should raise an error if it's not possible to take out balls" do
45
- expect { cell.take_out red }.to raise_error(EmptyCellError)
40
+ it "raises an error if it's not possible to take out balls" do
41
+ expect { cell.take_out rojo }.to raise_error(EmptyCellError)
46
42
  end
47
43
 
48
- it "should fail passing something that is not a color" do
44
+ it "fails passing something that is not a color" do
49
45
  expect { cell.put("not a color") }.to raise_error
50
46
  expect { cell.take_out(42) }.to raise_error
51
47
  expect { cell.are_there_balls?(Norte) }.to raise_error
52
48
  expect { cell.number_of_balls(nil) }.to raise_error
53
49
  end
54
50
 
55
- it "should empty its contents" do
51
+ it "clears its contents" do
56
52
  colors.each { |color| cell.put color }
57
53
 
58
54
  cell.empty!
59
55
 
60
- colors.each { |color| expect(cell.are_there_balls?(color)).to be_false }
56
+ colors.each { |color| expect(cell.are_there_balls?(color)).to be false }
61
57
  end
62
58
 
63
- it "should be empty if it doesn't have any balls" do
64
- expect(cell.empty?).to be_true
59
+ it "is empty if it doesn't have any balls" do
60
+ expect(cell.empty?).to be true
65
61
  end
66
62
 
67
- it "should not be empty it it has some balls" do
63
+ it "is not empty it it has some balls" do
68
64
  colors.each { |color| cell.put color }
69
- expect(cell.empty?).to be_false
65
+ expect(cell.empty?).to be false
70
66
  end
71
67
 
72
- end
68
+ end
@@ -1,48 +1,40 @@
1
1
  describe ExecutionContext do
2
2
 
3
- let(:context) { ExecutionContext.new }
3
+ let(:context) { clean_context }
4
4
 
5
5
  describe "variables context" do
6
6
 
7
- let(:negro) { Negro.new }
8
- let(:norte) { Norte.new }
9
-
10
- it "should allow to set & get a variable" do
7
+ it "allows to set/get a variable" do
11
8
  context.set 'myColor', negro
12
9
 
13
10
  expect(context.get('myColor')).to eq(negro)
14
11
  end
15
12
 
16
- it "should allow to set/get more than one variable" do
13
+ it "allows to set/get more than one variable" do
17
14
  context.set 'dir', norte
18
- context.set 'bool', true.to_gbs_bool
15
+ context.set 'bool', true_value
19
16
 
20
17
  expect(context.get('dir')).to eq(norte)
21
- expect(context.get('bool')).to eq(true.to_gbs_bool)
18
+ expect(context.get('bool')).to eq(true_value)
22
19
  end
23
20
 
24
- it "should raise an error when getting an undefined variable" do
25
- expect {
26
- context.get('undefined')
27
- }.to raise_error(UndefinedVariableError)
21
+ it "raises an error when trying to get an undefined variable" do
22
+ expect { context.get('undefined') }.to raise_error(UndefinedVariableError)
28
23
  end
29
24
 
30
25
  end
31
26
 
32
27
  describe ProgramExecutionContext do
33
28
 
34
- let(:context) { ProgramExecutionContext.for program }
35
- let(:program) { Program.new [], nil }
36
-
37
- it "should return self as program_context" do
29
+ it "is the program context itself" do
38
30
  expect(context.program_context).to eq(context)
39
31
  end
40
32
 
41
- it "should have a head" do
33
+ it "has a head" do
42
34
  expect(context.head).to be_a Head
43
35
  end
44
36
 
45
- it "should have a board" do
37
+ it "has a board" do
46
38
  expect(context.board).to be_a Board
47
39
  end
48
40
 
@@ -50,15 +42,37 @@ describe ExecutionContext do
50
42
 
51
43
  describe ProcedureExecutionContext do
52
44
 
53
- it "should return the program_context in which it is based" do
54
- program = Program.new [], nil
55
- program_context = ProgramExecutionContext.for program
56
- procedure_context = ProcedureExecutionContext.based_on program_context
45
+ let(:procedure_context) { ProcedureExecutionContext.based_on context }
46
+
47
+ it "returns the program context in which it is based" do
48
+ expect(procedure_context.program_context).to eq(context)
49
+ end
57
50
 
58
- expect(procedure_context.program_context).to eq(program_context)
51
+ it "shares the head with the outer context" do
52
+ expect(procedure_context.head).to eq(context.head)
59
53
  end
60
54
 
61
55
  end
62
56
 
63
- end
57
+ describe FunctionExecutionContext do
58
+
59
+ it "returns the program context in which it is based" do
60
+ function_context = FunctionExecutionContext.based_on context
61
+ expect(function_context.program_context).to eq(context)
62
+ end
64
63
 
64
+ it "has a new head, a copy of the outer context's head" do
65
+ context.head.put azul
66
+ function_context = FunctionExecutionContext.based_on context
67
+ function_context.head.put verde
68
+
69
+ expect(function_context.head).not_to eq(context.head)
70
+ expect(context.head.are_there_balls?(azul)).to be true
71
+ expect(function_context.head.are_there_balls?(azul)).to be true
72
+ expect(context.head.are_there_balls?(verde)).to be false
73
+ expect(function_context.head.are_there_balls?(verde)).to be true
74
+ end
75
+
76
+ end
77
+
78
+ end
@@ -1,67 +1,61 @@
1
1
  describe Head do
2
2
 
3
- it "should have a position, default 0;0" do
4
- head = Head.new
3
+ let(:head) { Head.new }
5
4
 
5
+ it "has a position, default 0;0" do
6
6
  expect(head.x_pos).to eq(0)
7
7
  expect(head.y_pos).to eq(0)
8
8
  end
9
9
 
10
- it "should answer the max size" do
10
+ it "answers the max size" do
11
11
  expect(Head::MAX_ROWS).to eq(9)
12
12
  expect(Head::MAX_COLS).to eq(9)
13
13
  end
14
14
 
15
- it "should allow to be created at a random position" do
15
+ it "allows to be created at a random position" do
16
16
  head = Head.at_random
17
17
 
18
- 100.times { expect(head.x_pos.between?(0, Head::MAX_ROWS-1)).to be_true }
19
- 100.times { expect(head.y_pos.between?(0, Head::MAX_COLS-1)).to be_true }
18
+ 100.times { expect(head.x_pos.between?(0, Head::MAX_ROWS-1)).to be true }
19
+ 100.times { expect(head.y_pos.between?(0, Head::MAX_COLS-1)).to be true }
20
20
  end
21
21
 
22
22
  describe "movements" do
23
23
 
24
- let(:head) { Head.new }
25
- let(:north) { Norte.new }
26
- let(:south) { Sur.new }
27
- let(:east) { Este.new }
28
- let(:west) { Oeste.new }
29
-
30
24
  context "valid" do
31
25
 
32
- it "should move north" do
33
- expect(head.can_move?(north)).to be_true
34
- expect { head.move(north) }.to_not raise_error
26
+ it "moves north" do
27
+ expect(head.can_move?(norte)).to be true
28
+ expect { head.move(norte) }.to_not raise_error
35
29
  expect(head.x_pos).to eq(0)
36
30
  expect(head.y_pos).to eq(1)
37
31
  end
38
32
 
39
- it "should move south" do
40
- head.move north
41
- expect(head.can_move?(south)).to be_true
42
- expect { head.move(south) }.to_not raise_error
33
+ it "moves south" do
34
+ head.move norte
35
+ expect(head.can_move?(sur)).to be true
36
+ expect { head.move(sur) }.to_not raise_error
43
37
  expect(head.x_pos).to eq(0)
44
38
  expect(head.y_pos).to eq(0)
45
39
  end
46
40
 
47
- it "should move east" do
48
- expect(head.can_move?(east)).to be_true
49
- expect { head.move(east) }.to_not raise_error
41
+ it "moves east" do
42
+ expect(head.can_move?(este)).to be true
43
+ expect { head.move(este) }.to_not raise_error
50
44
  expect(head.x_pos).to eq(1)
51
45
  expect(head.y_pos).to eq(0)
52
46
  end
53
47
 
54
- it "should move west" do
55
- head.move east
56
- expect(head.can_move?(west)).to be_true
57
- expect { head.move(west) }.to_not raise_error
48
+ it "moves west" do
49
+ head.move este
50
+ expect(head.can_move?(oeste)).to be true
51
+ expect { head.move(oeste) }.to_not raise_error
58
52
  expect(head.x_pos).to eq(0)
59
53
  expect(head.y_pos).to eq(0)
60
54
  end
61
55
 
62
- it "should go to the origin" do
63
- head.move east
64
- head.move north
56
+ it "goes to the origin" do
57
+ head.move este
58
+ head.move norte
65
59
  head.go_to_origin
66
60
  expect(head.x_pos).to eq(0)
67
61
  expect(head.y_pos).to eq(0)
@@ -71,36 +65,36 @@ describe Head do
71
65
 
72
66
  context "non valid" do
73
67
 
74
- it "should fail moving north" do
75
- (Head::MAX_COLS-1).times { head.move north }
68
+ it "fails moving north" do
69
+ (Head::MAX_COLS-1).times { head.move norte }
76
70
 
77
- expect(head.can_move?(north)).to be_false
78
- expect { head.move north }.to raise_error(OutOfBoardError)
71
+ expect(head.can_move?(norte)).to be false
72
+ expect { head.move norte }.to raise_error(OutOfBoardError)
79
73
  end
80
74
 
81
- it "should fail moving south" do
82
- expect(head.can_move?(south)).to be_false
83
- expect { head.move south }.to raise_error(OutOfBoardError)
75
+ it "fails moving south" do
76
+ expect(head.can_move?(sur)).to be false
77
+ expect { head.move sur }.to raise_error(OutOfBoardError)
84
78
  end
85
79
 
86
- it "should fail moving east" do
87
- (Head::MAX_ROWS-1).times { head.move east }
80
+ it "fails moving east" do
81
+ (Head::MAX_ROWS-1).times { head.move este }
88
82
 
89
- expect(head.can_move?(east)).to be_false
90
- expect { head.move east }.to raise_error(OutOfBoardError)
83
+ expect(head.can_move?(este)).to be false
84
+ expect { head.move este }.to raise_error(OutOfBoardError)
91
85
  end
92
86
 
93
- it "should fail moving west" do
94
- expect(head.can_move?(west)).to be_false
95
- expect { head.move west }.to raise_error(OutOfBoardError)
87
+ it "fails moving west" do
88
+ expect(head.can_move?(oeste)).to be false
89
+ expect { head.move oeste }.to raise_error(OutOfBoardError)
96
90
  end
97
91
 
98
- it "should fail if the argument is not a direction" do
99
- expect { head.move Azul.new }.
92
+ it "fails if the argument is not a direction" do
93
+ expect { head.move azul }.
100
94
  to raise_error(GobstonesTypeError, /is not a direction/)
101
95
  expect { head.move "not a direction" }.
102
96
  to raise_error(GobstonesTypeError, /is not a direction/)
103
- expect { head.move True.new }.
97
+ expect { head.move true_value }.
104
98
  to raise_error(GobstonesTypeError, /is not a direction/)
105
99
  expect { head.move 42 }.
106
100
  to raise_error(GobstonesTypeError, /is not a direction/)
@@ -112,26 +106,23 @@ describe Head do
112
106
 
113
107
  describe "board actions" do
114
108
 
115
- let(:head) { Head.new }
116
- let(:black) { Negro.new }
117
-
118
- it "should put balls across the board" do
119
- 3.times { head.put black }
120
- expect(head.are_there_balls?(black)).to be_true
121
- expect(head.number_of_balls(black)).to eq(3)
122
- head.move Norte.new
123
- 2.times { head.put black }
124
- expect(head.number_of_balls(black)).to eq(2)
125
- head.move Este.new
126
- 5.times { head.put black }
127
- expect(head.number_of_balls(black)).to eq(5)
109
+ it "puts balls across the board" do
110
+ 3.times { head.put negro }
111
+ expect(head.are_there_balls?(negro)).to be true
112
+ expect(head.number_of_balls(negro)).to eq(3)
113
+ head.move norte
114
+ 2.times { head.put negro }
115
+ expect(head.number_of_balls(negro)).to eq(2)
116
+ head.move este
117
+ 5.times { head.put negro }
118
+ expect(head.number_of_balls(negro)).to eq(5)
128
119
  end
129
120
 
130
- it "should take out balls across the board" do
131
- 4.times { head.put black }
132
- 4.times { head.take_out black }
121
+ it "takes out balls across the board" do
122
+ 4.times { head.put negro }
123
+ 4.times { head.take_out negro }
133
124
 
134
- expect(head.are_there_balls?(black)).to be_false
125
+ expect(head.are_there_balls?(negro)).to be false
135
126
  end
136
127
 
137
128
  end
@@ -12,4 +12,7 @@ require 'gobstones/parser/treetop_parser'
12
12
 
13
13
  include Gobstones::Lang
14
14
  include Gobstones::Runner
15
- include Gobstones::Parser
15
+ include Gobstones::Parser
16
+
17
+ require 'gobstones_lang_test_objects'
18
+ include GobstonesLangTestObjects
@@ -4,34 +4,34 @@ describe Gobstones, "type checker" do
4
4
 
5
5
  describe "puedeMover()" do
6
6
 
7
- it "should allow a direction as argument" do
8
- [Norte.new, Sur.new, Este.new, Oeste.new].each do |dir|
7
+ it "allows a direction as argument" do
8
+ [norte, sur, este, oeste].each do |dir|
9
9
  puede_mover_dir = PuedeMover.new dir
10
10
  result = puede_mover_dir.type_check
11
- expect(result.ok?).to be_true
11
+ expect(result.ok?).to be true
12
12
  end
13
13
  end
14
14
 
15
- it "should not allow a number as argument" do
16
- puede_mover_number = PuedeMover.new Number.new(42)
15
+ it "does not allow a number as argument" do
16
+ puede_mover_number = PuedeMover.new 42.to_gbs_num
17
17
  result = puede_mover_number.type_check
18
- expect(result.ok?).to be_false
18
+ expect(result.ok?).to be false
19
19
  end
20
20
 
21
- it "should not allow a color as argument" do
22
- puede_mover_color = PuedeMover.new Verde.new
21
+ it "does not allow a color as argument" do
22
+ puede_mover_color = PuedeMover.new verde
23
23
  result = puede_mover_color.type_check
24
- expect(result.ok?).to be_false
24
+ expect(result.ok?).to be false
25
25
  end
26
26
 
27
- it "should not allow a boolean as argument" do
28
- puede_mover_bool = PuedeMover.new True.new
27
+ it "does not allow a boolean as argument" do
28
+ puede_mover_bool = PuedeMover.new true_value
29
29
  result = puede_mover_bool.type_check
30
- expect(result.ok?).to be_false
30
+ expect(result.ok?).to be false
31
31
  end
32
32
 
33
33
  end
34
34
 
35
35
  end
36
36
 
37
- end
37
+ end