Class: TestLoop

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/tester/test_unit.rb

Instance Method Summary collapse

Instance Method Details

#test_whileObject



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/tester/test_unit.rb', line 198

def test_while
  assert_equal(WhileLoopNode, LangParser.new.calc_test("x = 5
                                                    #{$while} x < 10
                                                        x = x + 1
                                                    #{$end}"))

  assert_equal(10, LangParser.new.calc_test("x = 5
                                                    #{$while} x < 10
                                                        x = x + 1
                                                    #{$end}
                                                    x"))

  assert_equal(-10, LangParser.new.calc_test("x = 0
                                                    #{$while} x > -10
                                                        x = x - 1
                                                    #{$end}
                                                    x"))

  # assert_equal(0, LangParser.new.calc_test("x = 10
  #                                                   #{$while} -x < 0     # fundera på negering av variabler
  #                                                       x = x + 1
  #                                                   #{$end}
  #                                                   x"))
end