Class: TestVariables

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

Instance Method Summary collapse

Instance Method Details

#test_variablesObject



148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
# File 'lib/tester/test_unit.rb', line 148

def test_variables
  assert_equal(1, LangParser.new.calc_test("x = 1
                                            x"))

  assert_equal(1, LangParser.new.calc_test("x = 1
                                            x
                                            x"))

  assert_equal(1, LangParser.new.calc_test("x = 1
                                            x
                                            x + 1
                                            x"))

  assert_equal(3, LangParser.new.calc_test("x = 1
                                            x + 2"))

  assert_equal(2, LangParser.new.calc_test("x = 1
                                            x = 2
                                            x"))

  assert_equal(5, LangParser.new.calc_test("x = 1 + 2
                                            x + 2"))

  assert_equal(5, LangParser.new.calc_test("x = 1 + 2
                                            x = x + 2
                                            x"))
end