-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
statement_sequence,air_node: Generalize for-each loops
Closes #135.
- Loading branch information
Showing
5 changed files
with
81 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// This file is part of Asteria. | ||
// Copyleft 2018 - 2023, LH_Mouse. All wrongs reserved. | ||
|
||
#include "utils.hpp" | ||
#include "../asteria/simple_script.hpp" | ||
using namespace ::asteria; | ||
|
||
int main() | ||
{ | ||
Simple_Script code; | ||
code.reload_string( | ||
sref(__FILE__), __LINE__, sref(R"__( | ||
/////////////////////////////////////////////////////////////////////////////// | ||
var output; | ||
output = ""; | ||
for(each k, v -> ["a","b","c"]) | ||
output += std.string.format("$1=$2;", k, v); | ||
assert output == "0=a;1=b;2=c;"; | ||
output = ""; | ||
for(each k: v -> ["a","b","c"]) | ||
output += std.string.format("$1=$2;", k, v); | ||
assert output == "0=a;1=b;2=c;"; | ||
output = ""; | ||
for(each k = v -> ["a","b","c"]) | ||
output += std.string.format("$1=$2;", k, v); | ||
assert output == "0=a;1=b;2=c;"; | ||
output = ""; | ||
for(each v -> ["a","b","c"]) | ||
output += std.string.format("$1;", v); | ||
assert output == "a;b;c;"; | ||
/////////////////////////////////////////////////////////////////////////////// | ||
)__")); | ||
code.execute(); | ||
} |