lex: New lexical analyzer module for use in OVN.
[cascardo/ovs.git] / tests / ovn.at
1 AT_BANNER([OVN])
2
3 AT_SETUP([ovn -- lexer])
4 dnl For lines without =>, input and expected output are identical.
5 dnl For lines with =>, input precedes => and expected output follows =>.
6 AT_DATA([test-cases.txt], [dnl
7 foo bar baz quuxquuxquux _abcd_ a.b.c.d a123_.456
8 "abc\u0020def" => "abc def"
9 " => error("Input ends inside quoted string.")dnl "
10
11 a/*b*/c => a c
12 a//b c => a
13 a/**/b => a b
14 a/*/b => a error("`/*' without matching `*/'.")
15 a/*/**/b => a b
16 a/b => a error("`/' is only valid as part of `//' or `/*'.") b
17
18 0 1 12345 18446744073709551615
19 18446744073709551616 => error("Decimal constants must be less than 2**64.")
20 9999999999999999999999 => error("Decimal constants must be less than 2**64.")
21 01 => error("Decimal constants must not have leading zeros.")
22
23 0/0
24 0/1
25 1/0 => error("Value contains unmasked 1-bits.")
26 1/1
27 128/384
28 1/3
29 1/ => error("Integer constant expected.")
30
31 1/0x123 => error("Value and mask have incompatible formats.")
32
33 0x1234
34 0x01234 => 0x1234
35 0x0 => 0
36 0x000 => 0
37 0xfedcba9876543210
38 0XFEDCBA9876543210 => 0xfedcba9876543210
39 0xfedcba9876543210fedcba9876543210
40 0xfedcba9876543210fedcba98765432100 => error("Hexadecimal constant requires more than 128 bits.")
41 0x0000fedcba9876543210fedcba9876543210 => 0xfedcba9876543210fedcba9876543210
42 0x => error("Hex digits expected following 0x.")
43 0X => error("Hex digits expected following 0X.")
44 0x0/0x0 => 0/0
45 0x0/0x1 => 0/0x1
46 0x1/0x0 => error("Value contains unmasked 1-bits.")
47 0xffff/0x1ffff
48 0x. => error("Invalid syntax in hexadecimal constant.")
49
50 192.168.128.1 1.2.3.4 255.255.255.255 0.0.0.0
51 256.1.2.3 => error("Invalid numeric constant.")
52 192.168.0.0/16
53 192.168.0.0/255.255.0.0 => 192.168.0.0/16
54 192.168.0.0/255.255.255.0 => 192.168.0.0/24
55 192.168.0.0/255.255.0.255
56 192.168.0.0/255.0.0.0 => error("Value contains unmasked 1-bits.")
57 192.168.0.0/32
58 192.168.0.0/255.255.255.255 => 192.168.0.0/32
59
60 ::
61 ::1
62 ff00::1234 => ff00::1234
63 2001:db8:85a3::8a2e:370:7334
64 2001:db8:85a3:0:0:8a2e:370:7334 => 2001:db8:85a3::8a2e:370:7334
65 2001:0db8:85a3:0000:0000:8a2e:0370:7334 => 2001:db8:85a3::8a2e:370:7334
66 ::ffff:192.0.2.128
67 ::ffff:c000:0280 => ::ffff:192.0.2.128
68 ::1/::1
69 ::1/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff => ::1/128
70 ::1/128
71 ff00::/8
72 ff00::/ff00:: => ff00::/8
73
74 01:23:45:67:ab:cd
75 01:23:45:67:AB:CD => 01:23:45:67:ab:cd
76 fe:dc:ba:98:76:54
77 FE:DC:ba:98:76:54 => fe:dc:ba:98:76:54
78 01:00:00:00:00:00/01:00:00:00:00:00
79 ff:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff
80 fe:ff:ff:ff:ff:ff/ff:ff:ff:ff:ff:ff
81 ff:ff:ff:ff:ff:ff/fe:ff:ff:ff:ff:ff => error("Value contains unmasked 1-bits.")
82 fe:x => error("Invalid numeric constant.")
83 00:01:02:03:04:x => error("Invalid numeric constant.")
84
85 (){}[[]]==!=<<=>>=!&&||..,;= => ( ) { } [[ ]] == != < <= > >= ! && || .. , ; =
86 & => error("`&' is only valid as part of `&&'.")
87 | => error("`|' is only valid as part of `||'.")
88
89 ^ => error("Invalid character `^' in input.")
90 ])
91 AT_CAPTURE_FILE([input.txt])
92 sed 's/ =>.*//' test-cases.txt > input.txt
93 sed 's/.* => //' test-cases.txt > expout
94 AT_CHECK([ovstest test-ovn lex < input.txt], [0], [expout])
95 AT_CLEANUP