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
|
||||
}
|
||||
|
||||
switch x {
|
||||
switch x { // there is no "break" in SQF
|
||||
case 1:
|
||||
// ...
|
||||
break;
|
||||
case 2:
|
||||
// ...
|
||||
break;
|
||||
default:
|
||||
// ...
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -1,10 +1,8 @@
|
||||
switch x {
|
||||
case 1:
|
||||
x = 1;
|
||||
break;
|
||||
case 2:
|
||||
x = 2;
|
||||
break;
|
||||
default:
|
||||
x = 3;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user