redscript-mc 1.2.9 → 1.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -33
- package/README.zh.md +35 -33
- package/demo.gif +0 -0
- package/dist/ast/types.d.ts +6 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lexer/index.d.ts +1 -1
- package/dist/lexer/index.js +2 -0
- package/dist/lowering/index.d.ts +3 -0
- package/dist/lowering/index.js +60 -7
- package/dist/optimizer/dce.js +6 -0
- package/dist/parser/index.js +12 -0
- package/package.json +1 -1
- package/src/ast/types.ts +2 -0
- package/src/index.ts +1 -1
- package/src/lexer/index.ts +3 -1
- package/src/lowering/index.ts +64 -7
- package/src/optimizer/dce.ts +6 -0
- package/src/parser/index.ts +14 -0
- package/test-datapacks/README.md +67 -0
- package/test-datapacks/test_control_flow/data/minecraft/tags/function/load.json +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/__load.mcfunction +41 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/run_control_flow_tests.mcfunction +21 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/else_7.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/else_8.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/for_body_1.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/for_check_0.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/for_continue_2.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/for_exit_2.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/for_exit_3.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/merge_5.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/merge_6.mcfunction +2 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/merge_8.mcfunction +1 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/merge_9.mcfunction +1 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/then_3.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/then_4.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/then_6.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break/then_7.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_break.mcfunction +4 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_complex_conditions/else_1.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_complex_conditions/else_10.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_complex_conditions/else_4.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_complex_conditions/else_7.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_complex_conditions/merge_11.mcfunction +1 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_complex_conditions/merge_2.mcfunction +9 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_complex_conditions/merge_5.mcfunction +7 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_complex_conditions/merge_8.mcfunction +13 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_complex_conditions/then_0.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_complex_conditions/then_3.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_complex_conditions/then_6.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_complex_conditions/then_9.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_complex_conditions.mcfunction +12 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/else_7.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/else_8.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/for_body_1.mcfunction +7 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/for_check_0.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/for_continue_2.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/for_exit_2.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/for_exit_3.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/merge_5.mcfunction +8 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/merge_6.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/merge_8.mcfunction +1 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/merge_9.mcfunction +1 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/then_3.mcfunction +2 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/then_4.mcfunction +2 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/then_6.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue/then_7.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_continue.mcfunction +4 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/else_13.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/else_16.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/else_4.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/else_5.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_body_1.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_body_10.mcfunction +8 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_body_12.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_body_7.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_body_8.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_check_0.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_check_11.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_check_6.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_check_7.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_check_9.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_continue_13.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_continue_2.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_continue_9.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_exit_10.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_exit_11.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_exit_14.mcfunction +2 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_exit_2.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_exit_3.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/for_exit_8.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/merge_14.mcfunction +1 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/merge_17.mcfunction +1 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/merge_5.mcfunction +4 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/merge_6.mcfunction +4 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/then_12.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/then_15.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/then_3.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop/then_4.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_for_loop.mcfunction +4 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_foreach_at/foreach_0.mcfunction +2 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_foreach_at.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_foreach_selector/else_1.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_foreach_selector/foreach_0.mcfunction +4 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_foreach_selector/merge_2.mcfunction +2 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_foreach_selector/then_0.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_foreach_selector.mcfunction +11 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/else_1.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/else_13.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/else_16.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/else_4.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/merge_11.mcfunction +2 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/merge_14.mcfunction +1 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/merge_17.mcfunction +2 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/merge_2.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/merge_5.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/merge_8.mcfunction +6 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/then_0.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/then_12.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/then_15.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/then_3.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/then_6.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else/then_9.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_if_else.mcfunction +6 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_match/match_0.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_match/match_1.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_match/match_2.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_match/match_3.mcfunction +2 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_match/match_4.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_match/match_5.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_match/match_6.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_match/match_7.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_match/match_8.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_match/match_9.mcfunction +2 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_match.mcfunction +15 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop/else_13.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop/else_4.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop/loop_body_1.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop/loop_body_7.mcfunction +8 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop/loop_check_0.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop/loop_check_6.mcfunction +4 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop/loop_exit_2.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop/loop_exit_8.mcfunction +5 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop/merge_11.mcfunction +2 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop/merge_14.mcfunction +1 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop/merge_5.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop/then_12.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop/then_3.mcfunction +3 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop/then_9.mcfunction +2 -0
- package/test-datapacks/test_control_flow/data/test_control_flow/function/test_while_loop.mcfunction +3 -0
- package/test-datapacks/test_control_flow/pack.mcmeta +6 -0
- package/test-datapacks/test_control_flow.mcrs +242 -0
- package/test-datapacks/test_decorators/data/minecraft/tags/function/load.json +5 -0
- package/test-datapacks/test_decorators/data/minecraft/tags/function/tick.json +5 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/__load.mcfunction +20 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/__tick.mcfunction +3 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/every_second/merge_2.mcfunction +9 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/every_second/merge_5.mcfunction +1 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/every_second/then_0.mcfunction +1 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/every_second/then_3.mcfunction +4 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/every_second/tick_body.mcfunction +6 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/every_second/tick_skip.mcfunction +1 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/every_second.mcfunction +5 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/on_load.mcfunction +2 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/on_test_trigger.mcfunction +2 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/on_tick/merge_2.mcfunction +10 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/on_tick/merge_5.mcfunction +5 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/on_tick/merge_8.mcfunction +1 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/on_tick/then_0.mcfunction +1 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/on_tick/then_3.mcfunction +3 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/on_tick/then_6.mcfunction +4 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/on_tick.mcfunction +5 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/run_decorator_tests.mcfunction +7 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/setup_trigger_test.mcfunction +4 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/start_slow_tick_test.mcfunction +4 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/start_tick_test.mcfunction +4 -0
- package/test-datapacks/test_decorators/data/test_decorators/function/stop_tick_test.mcfunction +3 -0
- package/test-datapacks/test_decorators/pack.mcmeta +6 -0
- package/test-datapacks/test_decorators.mcrs +81 -0
- package/test-datapacks/test_events/data/minecraft/tags/function/load.json +5 -0
- package/test-datapacks/test_events/data/test_events/advancements/on_death_on_player_death.json +10 -0
- package/test-datapacks/test_events/data/test_events/function/__load.mcfunction +3 -0
- package/test-datapacks/test_events/data/test_events/function/on_player_death.mcfunction +3 -0
- package/test-datapacks/test_events/data/test_events/function/run_event_tests.mcfunction +5 -0
- package/test-datapacks/test_events/data/test_events/function/setup_events.mcfunction +3 -0
- package/test-datapacks/test_events/data/test_events/function/spawn_test_entity.mcfunction +3 -0
- package/test-datapacks/test_events/data/test_events/function/test_advancement_event.mcfunction +4 -0
- package/test-datapacks/test_events/pack.mcmeta +6 -0
- package/test-datapacks/test_events.mcrs +37 -0
- package/test-datapacks/test_fstrings/data/minecraft/tags/function/load.json +5 -0
- package/test-datapacks/test_fstrings/data/test_fstrings/function/__load.mcfunction +10 -0
- package/test-datapacks/test_fstrings/data/test_fstrings/function/run_fstring_tests.mcfunction +15 -0
- package/test-datapacks/test_fstrings/data/test_fstrings/function/test_actionbar_fstring.mcfunction +4 -0
- package/test-datapacks/test_fstrings/data/test_fstrings/function/test_announce.mcfunction +3 -0
- package/test-datapacks/test_fstrings/data/test_fstrings/function/test_multi_var_fstring.mcfunction +9 -0
- package/test-datapacks/test_fstrings/data/test_fstrings/function/test_say_fstring.mcfunction +4 -0
- package/test-datapacks/test_fstrings/data/test_fstrings/function/test_tell.mcfunction +3 -0
- package/test-datapacks/test_fstrings/data/test_fstrings/function/test_title_fstring.mcfunction +4 -0
- package/test-datapacks/test_fstrings/pack.mcmeta +6 -0
- package/test-datapacks/test_fstrings.mcrs +58 -0
- package/test-datapacks/test_timers/data/minecraft/tags/function/load.json +5 -0
- package/test-datapacks/test_timers/data/test_timers/function/__interval_0.mcfunction +3 -0
- package/test-datapacks/test_timers/data/test_timers/function/__interval_body_0.mcfunction +5 -0
- package/test-datapacks/test_timers/data/test_timers/function/__load.mcfunction +5 -0
- package/test-datapacks/test_timers/data/test_timers/function/__timeout_0.mcfunction +2 -0
- package/test-datapacks/test_timers/data/test_timers/function/run_timer_tests.mcfunction +5 -0
- package/test-datapacks/test_timers/data/test_timers/function/test_set_interval.mcfunction +5 -0
- package/test-datapacks/test_timers/data/test_timers/function/test_set_timeout.mcfunction +3 -0
- package/test-datapacks/test_timers/pack.mcmeta +6 -0
- package/test-datapacks/test_timers.mcrs +35 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
# RedScript In-Game Test Datapacks
|
|
2
|
+
|
|
3
|
+
These datapacks test various RedScript features in-game.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Copy the test folders to your Minecraft world's `datapacks` folder:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
.minecraft/saves/<world>/datapacks/
|
|
11
|
+
├── test_control_flow/
|
|
12
|
+
├── test_decorators/
|
|
13
|
+
├── test_events/
|
|
14
|
+
├── test_fstrings/
|
|
15
|
+
└── test_timers/
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Run `/reload` in-game.
|
|
19
|
+
|
|
20
|
+
## Test Commands
|
|
21
|
+
|
|
22
|
+
### Control Flow Tests
|
|
23
|
+
```
|
|
24
|
+
/function test_control_flow:run_control_flow_tests
|
|
25
|
+
```
|
|
26
|
+
Tests: `if`/`else`, `for`, `while`, `foreach`, `break`
|
|
27
|
+
|
|
28
|
+
### Decorator Tests
|
|
29
|
+
```
|
|
30
|
+
/function test_decorators:run_decorator_tests
|
|
31
|
+
/function test_decorators:start_tick_test
|
|
32
|
+
/function test_decorators:start_slow_tick_test
|
|
33
|
+
/function test_decorators:setup_trigger_test
|
|
34
|
+
```
|
|
35
|
+
Tests: `@load`, `@tick`, `@tick(rate=N)`, `@on_trigger`
|
|
36
|
+
|
|
37
|
+
### Event Tests
|
|
38
|
+
```
|
|
39
|
+
/function test_events:run_event_tests
|
|
40
|
+
```
|
|
41
|
+
Tests: `@on_death` (need to die in survival mode)
|
|
42
|
+
|
|
43
|
+
### F-String & Output Tests
|
|
44
|
+
```
|
|
45
|
+
/function test_fstrings:run_fstring_tests
|
|
46
|
+
```
|
|
47
|
+
Tests: `say`, `title`, `actionbar`, `tell`, f-strings with variables
|
|
48
|
+
|
|
49
|
+
### Timer Tests
|
|
50
|
+
```
|
|
51
|
+
/function test_timers:run_timer_tests
|
|
52
|
+
/function test_timers:test_set_timeout
|
|
53
|
+
/function test_timers:test_set_interval
|
|
54
|
+
```
|
|
55
|
+
Tests: `setTimeout`, `setInterval`
|
|
56
|
+
|
|
57
|
+
## Expected Results
|
|
58
|
+
|
|
59
|
+
- `[PASS]` — Test passed
|
|
60
|
+
- `[FAIL]` — Test failed
|
|
61
|
+
- `[INFO]` — Informational message
|
|
62
|
+
|
|
63
|
+
## Notes
|
|
64
|
+
|
|
65
|
+
- Run in survival mode for death events
|
|
66
|
+
- Some tests require waiting (timers, tick tests)
|
|
67
|
+
- Use `/reload` between test runs to reset state
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# RedScript runtime init
|
|
2
|
+
scoreboard objectives add rs dummy
|
|
3
|
+
scoreboard players set $test_counter rs 0
|
|
4
|
+
scoreboard players set $const_10 rs 10
|
|
5
|
+
scoreboard players set $const_5 rs 5
|
|
6
|
+
scoreboard players set $const_0 rs 0
|
|
7
|
+
scoreboard players set $const_20 rs 20
|
|
8
|
+
scoreboard players set $const_50 rs 50
|
|
9
|
+
scoreboard players set $const_25 rs 25
|
|
10
|
+
scoreboard players set $const_75 rs 75
|
|
11
|
+
scoreboard players set $const_0 rs 0
|
|
12
|
+
scoreboard players set $const_1 rs 1
|
|
13
|
+
scoreboard players set $const_5 rs 5
|
|
14
|
+
scoreboard players set $const_15 rs 15
|
|
15
|
+
scoreboard players set $const_2 rs 2
|
|
16
|
+
scoreboard players set $const_3 rs 3
|
|
17
|
+
scoreboard players set $const_6 rs 6
|
|
18
|
+
scoreboard players set $const_0 rs 0
|
|
19
|
+
scoreboard players set $const_3 rs 3
|
|
20
|
+
scoreboard players set $const_1 rs 1
|
|
21
|
+
scoreboard players set $const_5 rs 5
|
|
22
|
+
scoreboard players set $const_1 rs 1
|
|
23
|
+
scoreboard players set $const_0 rs 0
|
|
24
|
+
scoreboard players set $const_3 rs 3
|
|
25
|
+
scoreboard players set $const_0 rs 0
|
|
26
|
+
scoreboard players set $const_10 rs 10
|
|
27
|
+
scoreboard players set $const_5 rs 5
|
|
28
|
+
scoreboard players set $const_1 rs 1
|
|
29
|
+
scoreboard players set $const_0 rs 0
|
|
30
|
+
scoreboard players set $const_10 rs 10
|
|
31
|
+
scoreboard players set $const_2 rs 2
|
|
32
|
+
scoreboard players set $const_1 rs 1
|
|
33
|
+
scoreboard players set $const_20 rs 20
|
|
34
|
+
scoreboard players set $const_5 rs 5
|
|
35
|
+
scoreboard players set $const_10 rs 10
|
|
36
|
+
scoreboard players set $const_15 rs 15
|
|
37
|
+
scoreboard players set $const_100 rs 100
|
|
38
|
+
scoreboard players set $const_0 rs 0
|
|
39
|
+
scoreboard players set $const_2 rs 2
|
|
40
|
+
scoreboard players set $const_0 rs 0
|
|
41
|
+
scoreboard players set $const_75 rs 75
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# block: entry
|
|
2
|
+
say === Control Flow Tests ===
|
|
3
|
+
function test_control_flow:test_if_else
|
|
4
|
+
scoreboard players operation $_50 rs = $ret rs
|
|
5
|
+
function test_control_flow:test_for_loop
|
|
6
|
+
scoreboard players operation $_51 rs = $ret rs
|
|
7
|
+
function test_control_flow:test_while_loop
|
|
8
|
+
scoreboard players operation $_52 rs = $ret rs
|
|
9
|
+
function test_control_flow:test_foreach_selector
|
|
10
|
+
scoreboard players operation $_53 rs = $ret rs
|
|
11
|
+
function test_control_flow:test_foreach_at
|
|
12
|
+
scoreboard players operation $_54 rs = $ret rs
|
|
13
|
+
function test_control_flow:test_break
|
|
14
|
+
scoreboard players operation $_55 rs = $ret rs
|
|
15
|
+
function test_control_flow:test_continue
|
|
16
|
+
scoreboard players operation $_56 rs = $ret rs
|
|
17
|
+
function test_control_flow:test_complex_conditions
|
|
18
|
+
scoreboard players operation $_57 rs = $ret rs
|
|
19
|
+
function test_control_flow:test_match
|
|
20
|
+
scoreboard players operation $_58 rs = $ret rs
|
|
21
|
+
say === Tests Complete ===
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_body_1
|
|
2
|
+
scoreboard players set $_26 rs 0
|
|
3
|
+
execute if score $i rs = $const_5 rs run scoreboard players set $_26 rs 1
|
|
4
|
+
execute if score $_26 rs matches 1.. run function test_control_flow:test_break/then_4
|
|
5
|
+
execute if score $_26 rs matches ..0 run function test_control_flow:test_break/merge_6
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_check_0
|
|
2
|
+
scoreboard players set $_25 rs 0
|
|
3
|
+
execute if score $i rs < $const_10 rs run scoreboard players set $_25 rs 1
|
|
4
|
+
execute if score $_25 rs matches 1.. run function test_control_flow:test_break/for_body_1
|
|
5
|
+
execute if score $_25 rs matches ..0 run function test_control_flow:test_break/for_exit_3
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_exit_2
|
|
2
|
+
scoreboard players set $_28 rs 0
|
|
3
|
+
execute if score $found rs = $const_5 rs run scoreboard players set $_28 rs 1
|
|
4
|
+
execute if score $_28 rs matches 1.. run function test_control_flow:test_break/then_6
|
|
5
|
+
execute if score $_28 rs matches ..0 run function test_control_flow:test_break/else_7
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_exit_3
|
|
2
|
+
scoreboard players set $_28 rs 0
|
|
3
|
+
execute if score $found rs = $const_5 rs run scoreboard players set $_28 rs 1
|
|
4
|
+
execute if score $_28 rs matches 1.. run function test_control_flow:test_break/then_7
|
|
5
|
+
execute if score $_28 rs matches ..0 run function test_control_flow:test_break/else_8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# block: merge_8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# block: merge_9
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# block: merge_11
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# block: merge_2
|
|
2
|
+
scoreboard players set $_38 rs 0
|
|
3
|
+
execute if score $a rs > $const_100 rs run scoreboard players set $_38 rs 1
|
|
4
|
+
scoreboard players set $_39 rs 0
|
|
5
|
+
execute if score $b rs = $const_10 rs run scoreboard players set $_39 rs 1
|
|
6
|
+
scoreboard players operation $_40 rs = $_38 rs
|
|
7
|
+
execute if score $_40 rs matches ..0 run scoreboard players operation $_40 rs = $_39 rs
|
|
8
|
+
execute if score $_40 rs matches 1.. run function test_control_flow:test_complex_conditions/then_3
|
|
9
|
+
execute if score $_40 rs matches ..0 run function test_control_flow:test_complex_conditions/else_4
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# block: merge_5
|
|
2
|
+
scoreboard players set $_41 rs 0
|
|
3
|
+
execute if score $a rs > $b rs run scoreboard players set $_41 rs 1
|
|
4
|
+
scoreboard players set $_42 rs 0
|
|
5
|
+
execute if score $_41 rs = $const_0 rs run scoreboard players set $_42 rs 1
|
|
6
|
+
execute if score $_42 rs matches 1.. run function test_control_flow:test_complex_conditions/then_6
|
|
7
|
+
execute if score $_42 rs matches ..0 run function test_control_flow:test_complex_conditions/else_7
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# block: merge_8
|
|
2
|
+
scoreboard players set $_43 rs 0
|
|
3
|
+
execute if score $a rs < $b rs run scoreboard players set $_43 rs 1
|
|
4
|
+
scoreboard players set $_44 rs 0
|
|
5
|
+
execute if score $b rs < $c rs run scoreboard players set $_44 rs 1
|
|
6
|
+
scoreboard players operation $_45 rs = $_43 rs
|
|
7
|
+
execute if score $_45 rs matches 1.. run scoreboard players operation $_45 rs = $_44 rs
|
|
8
|
+
scoreboard players set $_46 rs 0
|
|
9
|
+
execute if score $a rs > $c rs run scoreboard players set $_46 rs 1
|
|
10
|
+
scoreboard players operation $_47 rs = $_43 rs
|
|
11
|
+
execute if score $_47 rs matches ..0 run scoreboard players operation $_47 rs = $_46 rs
|
|
12
|
+
execute if score $_47 rs matches 1.. run function test_control_flow:test_complex_conditions/then_9
|
|
13
|
+
execute if score $_47 rs matches ..0 run function test_control_flow:test_complex_conditions/else_10
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# block: entry
|
|
2
|
+
scoreboard players set $a rs 5
|
|
3
|
+
scoreboard players set $b rs 10
|
|
4
|
+
scoreboard players set $c rs 15
|
|
5
|
+
scoreboard players set $_35 rs 0
|
|
6
|
+
execute if score $const_5 rs < $const_10 rs run scoreboard players set $_35 rs 1
|
|
7
|
+
scoreboard players set $_36 rs 0
|
|
8
|
+
execute if score $const_10 rs < $const_15 rs run scoreboard players set $_36 rs 1
|
|
9
|
+
scoreboard players operation $_37 rs = $_35 rs
|
|
10
|
+
execute if score $_37 rs matches 1.. run scoreboard players operation $_37 rs = $_36 rs
|
|
11
|
+
execute if score $_37 rs matches 1.. run function test_control_flow:test_complex_conditions/then_0
|
|
12
|
+
execute if score $_37 rs matches ..0 run function test_control_flow:test_complex_conditions/else_1
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# block: for_body_1
|
|
2
|
+
scoreboard players operation $_30 rs = $i rs
|
|
3
|
+
scoreboard players operation $_30 rs %= $const_2 rs
|
|
4
|
+
scoreboard players set $_31 rs 0
|
|
5
|
+
execute unless score $_30 rs = $const_0 rs run scoreboard players set $_31 rs 1
|
|
6
|
+
execute if score $_31 rs matches 1.. run function test_control_flow:test_continue/then_4
|
|
7
|
+
execute if score $_31 rs matches ..0 run function test_control_flow:test_continue/merge_6
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_check_0
|
|
2
|
+
scoreboard players set $_29 rs 0
|
|
3
|
+
execute if score $i rs < $const_10 rs run scoreboard players set $_29 rs 1
|
|
4
|
+
execute if score $_29 rs matches 1.. run function test_control_flow:test_continue/for_body_1
|
|
5
|
+
execute if score $_29 rs matches ..0 run function test_control_flow:test_continue/for_exit_3
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_exit_2
|
|
2
|
+
scoreboard players set $_34 rs 0
|
|
3
|
+
execute if score $sum rs = $const_20 rs run scoreboard players set $_34 rs 1
|
|
4
|
+
execute if score $_34 rs matches 1.. run function test_control_flow:test_continue/then_6
|
|
5
|
+
execute if score $_34 rs matches ..0 run function test_control_flow:test_continue/else_7
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_exit_3
|
|
2
|
+
scoreboard players set $_34 rs 0
|
|
3
|
+
execute if score $sum rs = $const_20 rs run scoreboard players set $_34 rs 1
|
|
4
|
+
execute if score $_34 rs matches 1.. run function test_control_flow:test_continue/then_7
|
|
5
|
+
execute if score $_34 rs matches ..0 run function test_control_flow:test_continue/else_8
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# block: merge_5
|
|
2
|
+
scoreboard players operation $_32 rs = $sum rs
|
|
3
|
+
scoreboard players operation $_32 rs += $i rs
|
|
4
|
+
scoreboard players operation $sum rs = $_32 rs
|
|
5
|
+
scoreboard players operation $_33 rs = $i rs
|
|
6
|
+
scoreboard players operation $_33 rs += $const_1 rs
|
|
7
|
+
scoreboard players operation $i rs = $_33 rs
|
|
8
|
+
function test_control_flow:test_continue/for_check_0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# block: merge_8
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# block: merge_9
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# block: for_body_10
|
|
2
|
+
scoreboard players operation $_12 rs = $product rs
|
|
3
|
+
scoreboard players operation $_12 rs += $const_1 rs
|
|
4
|
+
scoreboard players operation $product rs = $_12 rs
|
|
5
|
+
scoreboard players operation $_13 rs = $b rs
|
|
6
|
+
scoreboard players operation $_13 rs += $const_1 rs
|
|
7
|
+
scoreboard players operation $b rs = $_13 rs
|
|
8
|
+
function test_control_flow:test_for_loop/for_check_9
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_check_0
|
|
2
|
+
scoreboard players set $_6 rs 0
|
|
3
|
+
execute if score $i rs <= $const_5 rs run scoreboard players set $_6 rs 1
|
|
4
|
+
execute if score $_6 rs matches 1.. run function test_control_flow:test_for_loop/for_body_1
|
|
5
|
+
execute if score $_6 rs matches ..0 run function test_control_flow:test_for_loop/for_exit_3
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_check_11
|
|
2
|
+
scoreboard players set $_11 rs 0
|
|
3
|
+
execute if score $b rs <= $const_3 rs run scoreboard players set $_11 rs 1
|
|
4
|
+
execute if score $_11 rs matches 1.. run function test_control_flow:test_for_loop/for_body_12
|
|
5
|
+
execute if score $_11 rs matches ..0 run function test_control_flow:test_for_loop/for_exit_14
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_check_6
|
|
2
|
+
scoreboard players set $_10 rs 0
|
|
3
|
+
execute if score $a rs <= $const_2 rs run scoreboard players set $_10 rs 1
|
|
4
|
+
execute if score $_10 rs matches 1.. run function test_control_flow:test_for_loop/for_body_7
|
|
5
|
+
execute if score $_10 rs matches ..0 run function test_control_flow:test_for_loop/for_exit_8
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_check_7
|
|
2
|
+
scoreboard players set $_10 rs 0
|
|
3
|
+
execute if score $a rs <= $const_2 rs run scoreboard players set $_10 rs 1
|
|
4
|
+
execute if score $_10 rs matches 1.. run function test_control_flow:test_for_loop/for_body_8
|
|
5
|
+
execute if score $_10 rs matches ..0 run function test_control_flow:test_for_loop/for_exit_10
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_check_9
|
|
2
|
+
scoreboard players set $_11 rs 0
|
|
3
|
+
execute if score $b rs <= $const_3 rs run scoreboard players set $_11 rs 1
|
|
4
|
+
execute if score $_11 rs matches 1.. run function test_control_flow:test_for_loop/for_body_10
|
|
5
|
+
execute if score $_11 rs matches ..0 run function test_control_flow:test_for_loop/for_exit_11
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_exit_10
|
|
2
|
+
scoreboard players set $_15 rs 0
|
|
3
|
+
execute if score $product rs = $const_6 rs run scoreboard players set $_15 rs 1
|
|
4
|
+
execute if score $_15 rs matches 1.. run function test_control_flow:test_for_loop/then_15
|
|
5
|
+
execute if score $_15 rs matches ..0 run function test_control_flow:test_for_loop/else_16
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_exit_2
|
|
2
|
+
scoreboard players set $_9 rs 0
|
|
3
|
+
execute if score $sum rs = $const_15 rs run scoreboard players set $_9 rs 1
|
|
4
|
+
execute if score $_9 rs matches 1.. run function test_control_flow:test_for_loop/then_3
|
|
5
|
+
execute if score $_9 rs matches ..0 run function test_control_flow:test_for_loop/else_4
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_exit_3
|
|
2
|
+
scoreboard players set $_9 rs 0
|
|
3
|
+
execute if score $sum rs = $const_15 rs run scoreboard players set $_9 rs 1
|
|
4
|
+
execute if score $_9 rs matches 1.. run function test_control_flow:test_for_loop/then_4
|
|
5
|
+
execute if score $_9 rs matches ..0 run function test_control_flow:test_for_loop/else_5
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# block: for_exit_8
|
|
2
|
+
scoreboard players set $_15 rs 0
|
|
3
|
+
execute if score $product rs = $const_6 rs run scoreboard players set $_15 rs 1
|
|
4
|
+
execute if score $_15 rs matches 1.. run function test_control_flow:test_for_loop/then_12
|
|
5
|
+
execute if score $_15 rs matches ..0 run function test_control_flow:test_for_loop/else_13
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# block: merge_14
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# block: merge_17
|