Skip to content

Commit

Permalink
Merge pull request #727 from Golmote/tests-nasm
Browse files Browse the repository at this point in the history
Add tests for NASM
  • Loading branch information
Golmote committed Sep 3, 2015
2 parents 75d2a09 + 561e46c commit 9bae186
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 0 deletions.
13 changes: 13 additions & 0 deletions tests/languages/nasm/comment_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
;
; foo

----------------------------------------------------

[
["comment", ";"],
["comment", "; foo"]
]

----------------------------------------------------

Checks for comments.
30 changes: 30 additions & 0 deletions tests/languages/nasm/keyword_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
BITS 16 BITS 32 BITS 64
[BITS 16] [BITS 32] [BITS 64]

section Foo.bar
section foobar:

extern _printf
global _main

CPU 8086
FLOAT DAZ
DEFAULT REL

----------------------------------------------------

[
["keyword", "BITS 16"], ["keyword", "BITS 32"], ["keyword", "BITS 64"],
["keyword", "[BITS 16]"], ["keyword", "[BITS 32]"], ["keyword", "[BITS 64]"],
["keyword", "section Foo.bar"],
["keyword", "section foobar:"],
["keyword", "extern _printf"],
["keyword", "global _main"],
["keyword", "CPU 8086"],
["keyword", "FLOAT DAZ"],
["keyword", "DEFAULT REL"]
]

----------------------------------------------------

Checks for keywords.
15 changes: 15 additions & 0 deletions tests/languages/nasm/label_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
foo42:
.foo:
..@foo:

----------------------------------------------------

[
["label", "foo42:"],
["label", ".foo:"],
["label", "..@foo:"]
]

----------------------------------------------------

Checks for labels.
97 changes: 97 additions & 0 deletions tests/languages/nasm/number_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
0xBadFace
0x4f.ab
0x4p2
0x2.ap-8
0x1p+1

0hBadFace
0h4f.ab
0h4p2
0h2.ap-8
0h1p+1
42fh
4ab2x

$4
$2a4f

0o75
0q75
75o
75q

0b0101
0y0101
0101b
0101y

0d42
0t42
42
3.14159
4.2e4
2e-1
3.1e+2
42d
3.14159d
4.2e4d
2e-1d
3.1e+2d
42t
3.14159t
4.2e4t
2e-1t
3.1e+2t

----------------------------------------------------

[
["number", "0xBadFace"],
["number", "0x4f.ab"],
["number", "0x4p2"],
["number", "0x2.ap-8"],
["number", "0x1p+1"],

["number", "0hBadFace"],
["number", "0h4f.ab"],
["number", "0h4p2"],
["number", "0h2.ap-8"],
["number", "0h1p+1"],
["number", "42fh"],
["number", "4ab2x"],

["number", "$4"],
["number", "$2a4f"],

["number", "0o75"],
["number", "0q75"],
["number", "75o"],
["number", "75q"],

["number", "0b0101"],
["number", "0y0101"],
["number", "0101b"],
["number", "0101y"],

["number", "0d42"],
["number", "0t42"],
["number", "42"],
["number", "3.14159"],
["number", "4.2e4"],
["number", "2e-1"],
["number", "3.1e+2"],
["number", "42d"],
["number", "3.14159d"],
["number", "4.2e4d"],
["number", "2e-1d"],
["number", "3.1e+2d"],
["number", "42t"],
["number", "3.14159t"],
["number", "4.2e4t"],
["number", "2e-1t"],
["number", "3.1e+2t"]
]

----------------------------------------------------

Checks for numbers.
17 changes: 17 additions & 0 deletions tests/languages/nasm/operator_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[ ]
* + - /
% < > =
& | $ !

----------------------------------------------------

[
["operator", "["], ["operator", "]"],
["operator", "*"], ["operator", "+"], ["operator", "-"], ["operator", "/"],
["operator", "%"], ["operator", "<"], ["operator", ">"], ["operator", "="],
["operator", "&"], ["operator", "|"], ["operator", "$"], ["operator", "!"]
]

----------------------------------------------------

Checks for operators.
43 changes: 43 additions & 0 deletions tests/languages/nasm/register_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
st0 st1
xmm1 xmm2
ymm1 ymm2
zmm1 zmm2
cr1 dr1 tr1
r1 r42
r1b r1w r1d
ax bx cx dx
eax ebx ecx edx
rax rbx rcx rdx
ah bh ch dh
al bl cl dl
bp sp si di
ebp esp esi edi
rbp rsp rsi rdi
cs ds es
fs gs ss

----------------------------------------------------

[
["register", "st0"], ["register", "st1"],
["register", "xmm1"], ["register", "xmm2"],
["register", "ymm1"], ["register", "ymm2"],
["register", "zmm1"], ["register", "zmm2"],
["register", "cr1"], ["register", "dr1"], ["register", "tr1"],
["register", "r1"], ["register", "r42"],
["register", "r1b"], ["register", "r1w"], ["register", "r1d"],
["register", "ax"], ["register", "bx"], ["register", "cx"], ["register", "dx"],
["register", "eax"], ["register", "ebx"], ["register", "ecx"], ["register", "edx"],
["register", "rax"], ["register", "rbx"], ["register", "rcx"], ["register", "rdx"],
["register", "ah"], ["register", "bh"], ["register", "ch"], ["register", "dh"],
["register", "al"], ["register", "bl"], ["register", "cl"], ["register", "dl"],
["register", "bp"], ["register", "sp"], ["register", "si"], ["register", "di"],
["register", "ebp"], ["register", "esp"], ["register", "esi"], ["register", "edi"],
["register", "rbp"], ["register", "rsp"], ["register", "rsi"], ["register", "rdi"],
["register", "cs"], ["register", "ds"], ["register", "es"],
["register", "fs"], ["register", "gs"], ["register", "ss"]
]

----------------------------------------------------

Checks for registers.
21 changes: 21 additions & 0 deletions tests/languages/nasm/string_feature.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
""
"fo\"o"
''
'fo\'o'
``
`fo\`o`

----------------------------------------------------

[
["string", "\"\""],
["string", "\"fo\\\"o\""],
["string", "''"],
["string", "'fo\\'o'"],
["string", "``"],
["string", "`fo\\`o`"]
]

----------------------------------------------------

Checks for strings.

0 comments on commit 9bae186

Please sign in to comment.