PageRenderTime 5ms CodeModel.GetById 2ms app.highlight 0ms RepoModel.GetById 2ms app.codeStats 0ms

/test/lib/automaton/test_automaton_01.e

http://github.com/tybor/Liberty
Specman e | 53 lines | 45 code | 8 blank | 0 comment | 1 complexity | 724e1d378cb4bd9794b7468816f7c450 MD5 | raw file
 1class TEST_AUTOMATON_01
 2
 3insert
 4   EIFFELTEST_TOOLS
 5
 6create {}
 7   make
 8
 9feature {}
10   make
11      do
12         assert_number("1".intern, True)
13         assert_number("a".intern, False)
14         assert_number("1.".intern, False)
15         assert_number("1.0".intern, True)
16         assert_number(".3".intern, True)
17         assert_number(".".intern, False)
18         assert_number("24.a3".intern, False)
19         assert_number("3.1415926535897932384626".intern, True)
20         assert_number("2.6.31".intern, False)
21      end
22
23   assert_number (num: FIXED_STRING; is_num: BOOLEAN)
24      local
25         aux: AUX_AUTOMATON_01
26      do
27         create aux.make(num)
28         aux.run
29         if is_num then
30            message_assert(agent is_a_number(num), aux.is_number)
31            message_assert(agent expected(num, aux) + " was expected", num.is_equal(aux.found_number))
32         else
33            message_assert(agent is_not_a_number(num), not aux.is_number)
34         end
35      end
36
37feature {} -- assert messages
38   is_a_number (num: FIXED_STRING): STRING
39      do
40         Result := num.out + once " is a number"
41      end
42
43   expected (num: FIXED_STRING; aux: AUX_AUTOMATON_01): STRING
44      do
45         Result := "Expected " + num.out + " but got " + aux.found_number.out
46      end
47
48   is_not_a_number (num: FIXED_STRING): STRING
49      do
50         Result := num.out + once " is not a number"
51      end
52
53end