Skip to content

Commit 2f908a0

Browse files
committed
tests
1 parent 630cc11 commit 2f908a0

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.jamplate.glucose.spec;
2+
3+
import org.jamplate.glucose.spec.tool.DebugSpec;
4+
import org.jamplate.impl.document.PseudoDocument;
5+
import org.jamplate.impl.unit.UnitImpl;
6+
import org.jamplate.model.Document;
7+
import org.jamplate.unit.Unit;
8+
import org.junit.jupiter.api.Test;
9+
10+
import static org.junit.jupiter.api.Assertions.fail;
11+
12+
public class ExamplesTest {
13+
@Test
14+
public void _99bottlesOfBeerOnTheWall() {
15+
Document document = new PseudoDocument(
16+
"Test",
17+
"#declare $i 99",
18+
"#declare $noun 'bottles'",
19+
"",
20+
"#while $i > 0",
21+
" #message $i ' ' $noun \" of beer on the wall,\\n\"",
22+
" #message $i ' ' $noun \" of beer.\\n\"",
23+
" #message \"Take one down, pass it around,\\n\"",
24+
"",
25+
" #declare $i $i - 1",
26+
"",
27+
" #if $i == 0",
28+
" #message \"No bottles of beer on the wall.\\n\\n\"",
29+
" #else",
30+
" #if $i == 1",
31+
" #declare $noun 'bottle'",
32+
"#else",
33+
" #endif",
34+
"",
35+
" #message $i ' ' $noun \" of beer on the wall.\\n\\n\"",
36+
" #endif",
37+
"#endwhile",
38+
"",
39+
"#message \"No bottles of beer on the wall,\\n\"",
40+
"#message \"No bottles of beer.\\n\"",
41+
"#message \"Go to the store, buy some more,\\n\"",
42+
"#message \"99 bottles of beer on the wall.\\n\""
43+
);
44+
45+
Unit unit = new UnitImpl(new GlucoseSpec(DebugSpec.INSTANCE));
46+
47+
if (
48+
!unit.initialize(document) ||
49+
!unit.parse(document) ||
50+
!unit.analyze(document) ||
51+
!unit.compile(document) ||
52+
!unit.execute(document)
53+
) {
54+
unit.diagnostic();
55+
fail("Test not completed");
56+
}
57+
}
58+
}

0 commit comments

Comments
 (0)