Fixed switch in test and readme.

This commit is contained in:
Marvin Blum
2015-10-28 17:50:46 +01:00
parent a64bef135d
commit bba215cd8d
6 changed files with 16 additions and 17 deletions

View File

@@ -90,13 +90,11 @@ each allUnits { // foreach, iterates over all units in this case
// element is available as _x here
}
switch x {
switch x { // there is no "break" in SQF
case 1:
// ...
break;
case 2:
// ...
break;
default:
// ...
}

View File

@@ -1,6 +1,4 @@
var array = [1, 2, 3];
var x = array[0];
if array[(1-1)+10/10] == 2 {
foo();
switch x {
case 1:
x = 1;
}

View File

@@ -49,7 +49,10 @@ func TestParserForeach(t *testing.T) {
}
func TestParserSwitch(t *testing.T) {
got := getCompiled(t, "test/tokenizer_switch.asl")
want := "switch (x) do {\r\ncase 1:\r\n{\r\nx = 1;\r\n};\r\ncase 2:\r\n{\r\nx = 2;\r\n};\r\ndefault:\r\n{\r\nx = 3;\r\n};\r\n};\r\n"
equal(t, got, want)
}
func TestParserFunction(t *testing.T) {

View File

@@ -47,7 +47,7 @@ func TestTokenizerForach(t *testing.T) {
func TestTokenizerSwitch(t *testing.T) {
got := getTokens(t, "test/tokenizer_switch.asl")
want := []string{"switch", "x", "{", "case", "1", ":", "x", "=", "1", ";", "break", ";", "case", "2", ":", "x", "=", "2", ";", "break", ";", "default", ":", "x", "=", "3", ";", "}"}
want := []string{"switch", "x", "{", "case", "1", ":", "x", "=", "1", ";", "case", "2", ":", "x", "=", "2", ";", "default", ":", "x", "=", "3", ";", "}"}
compareLength(t, &got, &want)
compareTokens(t, &got, &want)

View File

@@ -22,11 +22,13 @@ type ASLFile struct {
newname string
}
var recursive bool = false
var pretty bool = false
var exit bool = false
var aslFiles []ASLFile
var inDir string
var (
recursive bool = false
pretty bool = false
exit bool = false
aslFiles []ASLFile
inDir string
)
func usage() {
fmt.Println("Usage: asl [-v|-r|-pretty|--help] <input directory> <output directory>\n")

View File

@@ -1,10 +1,8 @@
switch x {
case 1:
x = 1;
break;
case 2:
x = 2;
break;
default:
x = 3;
}