mirror of
https://github.com/Kugelschieber/asl.git
synced 2026-01-18 12:00:25 +00:00
Fixed switch in test and readme.
This commit is contained in:
@@ -90,13 +90,11 @@ each allUnits { // foreach, iterates over all units in this case
|
|||||||
// element is available as _x here
|
// element is available as _x here
|
||||||
}
|
}
|
||||||
|
|
||||||
switch x {
|
switch x { // there is no "break" in SQF
|
||||||
case 1:
|
case 1:
|
||||||
// ...
|
// ...
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
// ...
|
// ...
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
// ...
|
// ...
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
var array = [1, 2, 3];
|
switch x {
|
||||||
var x = array[0];
|
case 1:
|
||||||
|
x = 1;
|
||||||
if array[(1-1)+10/10] == 2 {
|
|
||||||
foo();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,10 @@ func TestParserForeach(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestParserSwitch(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) {
|
func TestParserFunction(t *testing.T) {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ func TestTokenizerForach(t *testing.T) {
|
|||||||
|
|
||||||
func TestTokenizerSwitch(t *testing.T) {
|
func TestTokenizerSwitch(t *testing.T) {
|
||||||
got := getTokens(t, "test/tokenizer_switch.asl")
|
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)
|
compareLength(t, &got, &want)
|
||||||
compareTokens(t, &got, &want)
|
compareTokens(t, &got, &want)
|
||||||
|
|||||||
@@ -22,11 +22,13 @@ type ASLFile struct {
|
|||||||
newname string
|
newname string
|
||||||
}
|
}
|
||||||
|
|
||||||
var recursive bool = false
|
var (
|
||||||
var pretty bool = false
|
recursive bool = false
|
||||||
var exit bool = false
|
pretty bool = false
|
||||||
var aslFiles []ASLFile
|
exit bool = false
|
||||||
var inDir string
|
aslFiles []ASLFile
|
||||||
|
inDir string
|
||||||
|
)
|
||||||
|
|
||||||
func usage() {
|
func usage() {
|
||||||
fmt.Println("Usage: asl [-v|-r|-pretty|--help] <input directory> <output directory>\n")
|
fmt.Println("Usage: asl [-v|-r|-pretty|--help] <input directory> <output directory>\n")
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
switch x {
|
switch x {
|
||||||
case 1:
|
case 1:
|
||||||
x = 1;
|
x = 1;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
x = 2;
|
x = 2;
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
x = 3;
|
x = 3;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user