Remove procedural-waves from tests

main
Shad Amethyst 1 year ago
parent 3efaf5b7e2
commit 790da1870b

@ -1,3 +1,5 @@
#![feature(fs_try_exists)]
use std::path::{Path, PathBuf};
use basic_to_mindustry::common::Config;
@ -55,6 +57,15 @@ fn test_examples_opt() {
panic!("Basic program in examples/ has an invalid filename: {}", file_name);
};
let opt_0 = format!("tests/examples/{}.0.mlog", program_name);
if !std::fs::try_exists(&opt_0).unwrap() {
continue
}
let opt_0 = std::fs::read_to_string(opt_0).unwrap_or_else(|e| {
panic!("Couldn't open tests/examples/{}.0.mlog: {:?}", program_name, e);
});
let tokenized = tokenize(&file).unwrap_or_else(|e| {
panic!("Error tokenizing {:?}: {:?}", file_name, e);
});
@ -63,9 +74,6 @@ fn test_examples_opt() {
});
let translated = translate_ast(&parsed, &mut Default::default(), &config);
let opt_0 = std::fs::read_to_string(format!("tests/examples/{}.0.mlog", program_name)).unwrap_or_else(|e| {
panic!("Couldn't open tests/examples/{}.0.mlog: {:?}", program_name, e);
});
pretty_assertions::assert_eq!(opt_0.trim(), format!("{}", translated).trim());

@ -1,421 +0,0 @@
set wave 0
set main__tmp_0 @time
set main__tmp_1 120000
op add timeout main__tmp_0 main__tmp_1
initial_wait:
set main__tmp_2 timeout
set main__tmp_3 @time
op sub remaining main__tmp_2 main__tmp_3
set main__tmp_5 remaining
set main__tmp_6 0
op lessThanEq main__tmp_4 main__tmp_5 main__tmp_6
jump main__label_0_endif notEqual main__tmp_4 true
jump main always 0 0
main__label_0_endif:
set main__tmp_7 "[red]Enemies[white] approaching: "
print main__tmp_7
set main__tmp_9 remaining
set main__tmp_10 1000
op div main__tmp_8 main__tmp_9 main__tmp_10
op ceil main__tmp_8 main__tmp_8 0
print main__tmp_8
set main__tmp_11 " s"
print main__tmp_11
message mission
set main__tmp_12 0.5
wait main__tmp_12
jump initial_wait always 0 0
main:
set main__tmp_13 wave
set main__tmp_14 1
op add wave main__tmp_13 main__tmp_14
set main__tmp_17 wave
set main__tmp_18 4
op div main__tmp_15 main__tmp_17 main__tmp_18
set main__tmp_16 0.75
op pow progression main__tmp_15 main__tmp_16
set main__tmp_23 progression
set main__tmp_24 2
op div main__tmp_21 main__tmp_23 main__tmp_24
set main__tmp_25 progression
set main__tmp_26 2
op div main__tmp_22 main__tmp_25 main__tmp_26
op rand main__tmp_22 main__tmp_22 0
op add main__tmp_19 main__tmp_21 main__tmp_22
set main__tmp_20 10
op min progression main__tmp_19 main__tmp_20
set main__tmp_29 2
set main__tmp_31 progression
op sqrt main__tmp_31 main__tmp_31 0
set main__tmp_32 4
op mul main__tmp_30 main__tmp_31 main__tmp_32
op add main__tmp_27 main__tmp_29 main__tmp_30
set main__tmp_33 progression
set main__tmp_34 2
op mul main__tmp_28 main__tmp_33 main__tmp_34
op rand main__tmp_28 main__tmp_28 0
op add units main__tmp_27 main__tmp_28
set main__tmp_35 units
set main__tmp_36 1
op mul units main__tmp_35 main__tmp_36
op ceil units units 0
set tank_units units
op rand tank_units tank_units 0
op floor tank_units tank_units 0
set main__tmp_37 units
set main__tmp_38 tank_units
op sub mech_units main__tmp_37 main__tmp_38
op rand mech_units mech_units 0
op floor mech_units mech_units 0
set main__tmp_41 units
set main__tmp_42 tank_units
op sub main__tmp_39 main__tmp_41 main__tmp_42
set main__tmp_40 mech_units
op sub air_units main__tmp_39 main__tmp_40
set spawnx 30
set spawny 50
jump spawn_tank always 0 0
spawn_tank_end:
jump spawn_mech always 0 0
spawn_mech_end:
set spawnx 20
jump spawn_air always 0 0
spawn_air_end:
set main__tmp_43 wave
set main__tmp_44 cell1
set main__tmp_45 1
write main__tmp_43 main__tmp_44 main__tmp_45
set main__tmp_46 cell1
set main__tmp_47 0
read timeout main__tmp_46 main__tmp_47
set main__tmp_48 @time
set main__tmp_50 timeout
set main__tmp_51 1000
op mul main__tmp_49 main__tmp_50 main__tmp_51
op add timeout main__tmp_48 main__tmp_49
main_wait:
set main__tmp_52 timeout
set main__tmp_53 @time
op sub remaining main__tmp_52 main__tmp_53
set main__tmp_55 remaining
set main__tmp_56 0
op lessThanEq main__tmp_54 main__tmp_55 main__tmp_56
jump main__label_1_endif notEqual main__tmp_54 true
jump main always 0 0
main__label_1_endif:
set main__tmp_57 "[yellow]Wave "
print main__tmp_57
set main__tmp_58 wave
print main__tmp_58
set main__tmp_59 "[white] - "
print main__tmp_59
set main__tmp_60 "Next wave: "
print main__tmp_60
set main__tmp_62 remaining
set main__tmp_63 1000
op div main__tmp_61 main__tmp_62 main__tmp_63
op ceil main__tmp_61 main__tmp_61 0
print main__tmp_61
set main__tmp_64 " s"
print main__tmp_64
message mission
set main__tmp_65 0.5
wait main__tmp_65
jump main_wait always 0 0
spawn_tank:
set spawned 0
spawn_tank_loop:
set roll progression
op rand roll roll 0
set main__tmp_67 roll
set main__tmp_68 3
op greaterThanEq main__tmp_66 main__tmp_67 main__tmp_68
jump main__label_2_else notEqual main__tmp_66 true
set main__tmp_70 roll
set main__tmp_71 4
op greaterThanEq main__tmp_69 main__tmp_70 main__tmp_71
jump main__label_4_else notEqual main__tmp_69 true
set main__tmp_72 @conquer
set main__tmp_73 spawnx
set main__tmp_74 spawny
set main__tmp_75 0
set main__tmp_76 @crux
set main__tmp_77 _
spawn main__tmp_72 main__tmp_73 main__tmp_74 main__tmp_75 main__tmp_76 main__tmp_77
set main__tmp_78 spawnx
set main__tmp_79 5.75
op sub spawnx main__tmp_78 main__tmp_79
jump main__label_5_endif always 0 0
main__label_4_else:
set main__tmp_80 @vanquish
set main__tmp_81 spawnx
set main__tmp_82 spawny
set main__tmp_83 0
set main__tmp_84 @crux
set main__tmp_85 _
spawn main__tmp_80 main__tmp_81 main__tmp_82 main__tmp_83 main__tmp_84 main__tmp_85
set main__tmp_86 spawnx
set main__tmp_87 3.5
op sub spawnx main__tmp_86 main__tmp_87
main__label_5_endif:
jump main__label_3_endif always 0 0
main__label_2_else:
set main__tmp_89 roll
set main__tmp_90 2
op greaterThanEq main__tmp_88 main__tmp_89 main__tmp_90
jump main__label_6_else notEqual main__tmp_88 true
set main__tmp_91 @precept
set main__tmp_92 spawnx
set main__tmp_93 spawny
set main__tmp_94 0
set main__tmp_95 @crux
set main__tmp_96 _
spawn main__tmp_91 main__tmp_92 main__tmp_93 main__tmp_94 main__tmp_95 main__tmp_96
set main__tmp_97 spawnx
set main__tmp_98 3.25
op sub spawnx main__tmp_97 main__tmp_98
jump main__label_7_endif always 0 0
main__label_6_else:
set main__tmp_100 roll
set main__tmp_101 1
op greaterThanEq main__tmp_99 main__tmp_100 main__tmp_101
jump main__label_8_else notEqual main__tmp_99 true
set main__tmp_102 @locus
set main__tmp_103 spawnx
set main__tmp_104 spawny
set main__tmp_105 0
set main__tmp_106 @crux
set main__tmp_107 _
spawn main__tmp_102 main__tmp_103 main__tmp_104 main__tmp_105 main__tmp_106 main__tmp_107
set main__tmp_108 spawnx
set main__tmp_109 1
op sub spawnx main__tmp_108 main__tmp_109
jump main__label_9_endif always 0 0
main__label_8_else:
set main__tmp_110 @stell
set main__tmp_111 spawnx
set main__tmp_112 spawny
set main__tmp_113 0
set main__tmp_114 @crux
set main__tmp_115 _
spawn main__tmp_110 main__tmp_111 main__tmp_112 main__tmp_113 main__tmp_114 main__tmp_115
set main__tmp_116 spawnx
set main__tmp_117 1
op sub spawnx main__tmp_116 main__tmp_117
main__label_9_endif:
main__label_7_endif:
main__label_3_endif:
set main__tmp_119 spawnx
set main__tmp_120 10
op lessThan main__tmp_118 main__tmp_119 main__tmp_120
jump main__label_10_endif notEqual main__tmp_118 true
set spawnx 10
main__label_10_endif:
set main__tmp_121 spawned
set main__tmp_122 1
op add spawned main__tmp_121 main__tmp_122
set main__tmp_124 spawned
set main__tmp_125 tank_units
op lessThan main__tmp_123 main__tmp_124 main__tmp_125
jump main__label_11_endif notEqual main__tmp_123 true
jump spawn_tank_loop always 0 0
main__label_11_endif:
jump spawn_tank_end always 0 0
spawn_mech:
set spawned 0
spawn_mech_loop:
set roll progression
op rand roll roll 0
set main__tmp_127 roll
set main__tmp_128 3
op greaterThanEq main__tmp_126 main__tmp_127 main__tmp_128
jump main__label_12_else notEqual main__tmp_126 true
set main__tmp_130 roll
set main__tmp_131 4
op greaterThanEq main__tmp_129 main__tmp_130 main__tmp_131
jump main__label_14_else notEqual main__tmp_129 true
set main__tmp_132 @collaris
set main__tmp_133 spawnx
set main__tmp_134 spawny
set main__tmp_135 0
set main__tmp_136 @crux
set main__tmp_137 _
spawn main__tmp_132 main__tmp_133 main__tmp_134 main__tmp_135 main__tmp_136 main__tmp_137
set main__tmp_138 spawnx
set main__tmp_139 5.5
op sub spawnx main__tmp_138 main__tmp_139
jump main__label_15_endif always 0 0
main__label_14_else:
set main__tmp_140 @tecta
set main__tmp_141 spawnx
set main__tmp_142 spawny
set main__tmp_143 0
set main__tmp_144 @crux
set main__tmp_145 _
spawn main__tmp_140 main__tmp_141 main__tmp_142 main__tmp_143 main__tmp_144 main__tmp_145
set main__tmp_146 spawnx
set main__tmp_147 2.87
op sub spawnx main__tmp_146 main__tmp_147
main__label_15_endif:
jump main__label_13_endif always 0 0
main__label_12_else:
set main__tmp_149 roll
set main__tmp_150 2
op greaterThanEq main__tmp_148 main__tmp_149 main__tmp_150
jump main__label_16_else notEqual main__tmp_148 true
set main__tmp_151 @anthicus
set main__tmp_152 spawnx
set main__tmp_153 spawny
set main__tmp_154 0
set main__tmp_155 @crux
set main__tmp_156 _
spawn main__tmp_151 main__tmp_152 main__tmp_153 main__tmp_154 main__tmp_155 main__tmp_156
set main__tmp_157 spawnx
set main__tmp_158 2.62
op sub spawnx main__tmp_157 main__tmp_158
jump main__label_17_endif always 0 0
main__label_16_else:
set main__tmp_160 roll
set main__tmp_161 1
op greaterThanEq main__tmp_159 main__tmp_160 main__tmp_161
jump main__label_18_else notEqual main__tmp_159 true
set main__tmp_162 @cleroi
set main__tmp_163 spawnx
set main__tmp_164 spawny
set main__tmp_165 0
set main__tmp_166 @crux
set main__tmp_167 _
spawn main__tmp_162 main__tmp_163 main__tmp_164 main__tmp_165 main__tmp_166 main__tmp_167
set main__tmp_168 spawnx
set main__tmp_169 1
op sub spawnx main__tmp_168 main__tmp_169
jump main__label_19_endif always 0 0
main__label_18_else:
set main__tmp_170 @merui
set main__tmp_171 spawnx
set main__tmp_172 spawny
set main__tmp_173 0
set main__tmp_174 @crux
set main__tmp_175 _
spawn main__tmp_170 main__tmp_171 main__tmp_172 main__tmp_173 main__tmp_174 main__tmp_175
set main__tmp_176 spawnx
set main__tmp_177 1
op sub spawnx main__tmp_176 main__tmp_177
main__label_19_endif:
main__label_17_endif:
main__label_13_endif:
set main__tmp_179 spawnx
set main__tmp_180 10
op lessThan main__tmp_178 main__tmp_179 main__tmp_180
jump main__label_20_endif notEqual main__tmp_178 true
set spawnx 10
main__label_20_endif:
set main__tmp_181 spawned
set main__tmp_182 1
op add spawned main__tmp_181 main__tmp_182
set main__tmp_184 spawned
set main__tmp_185 mech_units
op lessThan main__tmp_183 main__tmp_184 main__tmp_185
jump main__label_21_endif notEqual main__tmp_183 true
jump spawn_mech_loop always 0 0
main__label_21_endif:
jump spawn_mech_end always 0 0
spawn_air:
set spawned 0
spawn_air_loop:
set roll progression
op rand roll roll 0
set main__tmp_187 roll
set main__tmp_188 3
op greaterThanEq main__tmp_186 main__tmp_187 main__tmp_188
jump main__label_22_else notEqual main__tmp_186 true
set main__tmp_190 roll
set main__tmp_191 4
op greaterThanEq main__tmp_189 main__tmp_190 main__tmp_191
jump main__label_24_else notEqual main__tmp_189 true
set main__tmp_192 @disrupt
set main__tmp_193 spawnx
set main__tmp_194 spawny
set main__tmp_195 0
set main__tmp_196 @crux
set main__tmp_197 _
spawn main__tmp_192 main__tmp_193 main__tmp_194 main__tmp_195 main__tmp_196 main__tmp_197
set main__tmp_198 spawnx
set main__tmp_199 5.75
op sub spawnx main__tmp_198 main__tmp_199
jump main__label_25_endif always 0 0
main__label_24_else:
set main__tmp_200 @quell
set main__tmp_201 spawnx
set main__tmp_202 spawny
set main__tmp_203 0
set main__tmp_204 @crux
set main__tmp_205 _
spawn main__tmp_200 main__tmp_201 main__tmp_202 main__tmp_203 main__tmp_204 main__tmp_205
set main__tmp_206 spawnx
set main__tmp_207 4.5
op sub spawnx main__tmp_206 main__tmp_207
main__label_25_endif:
jump main__label_23_endif always 0 0
main__label_22_else:
set main__tmp_209 roll
set main__tmp_210 2
op greaterThanEq main__tmp_208 main__tmp_209 main__tmp_210
jump main__label_26_else notEqual main__tmp_208 true
set main__tmp_211 @obviate
set main__tmp_212 spawnx
set main__tmp_213 spawny
set main__tmp_214 0
set main__tmp_215 @crux
set main__tmp_216 _
spawn main__tmp_211 main__tmp_212 main__tmp_213 main__tmp_214 main__tmp_215 main__tmp_216
set main__tmp_217 spawnx
set main__tmp_218 3.12
op sub spawnx main__tmp_217 main__tmp_218
jump main__label_27_endif always 0 0
main__label_26_else:
set main__tmp_220 roll
set main__tmp_221 1
op greaterThanEq main__tmp_219 main__tmp_220 main__tmp_221
jump main__label_28_else notEqual main__tmp_219 true
set main__tmp_222 @avert
set main__tmp_223 spawnx
set main__tmp_224 spawny
set main__tmp_225 0
set main__tmp_226 @crux
set main__tmp_227 _
spawn main__tmp_222 main__tmp_223 main__tmp_224 main__tmp_225 main__tmp_226 main__tmp_227
set main__tmp_228 spawnx
set main__tmp_229 1
op sub spawnx main__tmp_228 main__tmp_229
jump main__label_29_endif always 0 0
main__label_28_else:
set main__tmp_230 @elude
set main__tmp_231 spawnx
set main__tmp_232 spawny
set main__tmp_233 0
set main__tmp_234 @crux
set main__tmp_235 _
spawn main__tmp_230 main__tmp_231 main__tmp_232 main__tmp_233 main__tmp_234 main__tmp_235
set main__tmp_236 spawnx
set main__tmp_237 1
op sub spawnx main__tmp_236 main__tmp_237
main__label_29_endif:
main__label_27_endif:
main__label_23_endif:
set main__tmp_239 spawnx
set main__tmp_240 10
op lessThan main__tmp_238 main__tmp_239 main__tmp_240
jump main__label_30_endif notEqual main__tmp_238 true
set spawnx 10
main__label_30_endif:
set main__tmp_241 spawned
set main__tmp_242 1
op add spawned main__tmp_241 main__tmp_242
set main__tmp_244 spawned
set main__tmp_245 air_units
op lessThan main__tmp_243 main__tmp_244 main__tmp_245
jump main__label_31_endif notEqual main__tmp_243 true
jump spawn_air_loop always 0 0
main__label_31_endif:
jump spawn_air_end always 0 0

@ -1,200 +0,0 @@
set wave 0
set main__tmp_0 @time
op add timeout main__tmp_0 120000
initial_wait:
set main__tmp_3 @time
op sub remaining timeout main__tmp_3
jump main__label_0_endif greaterThan remaining 0
jump main always 0 0
main__label_0_endif:
print "[red]Enemies[white] approaching: "
op div main__tmp_8 remaining 1000
op ceil main__tmp_8 main__tmp_8 0
print main__tmp_8
print " s"
message mission
wait 0.5
jump initial_wait always 0 0
main:
op add wave wave 1
op div main__tmp_15 wave 4
op pow progression main__tmp_15 0.75
op div main__tmp_21 progression 2
op div main__tmp_22 progression 2
op rand main__tmp_22 main__tmp_22 0
op add main__tmp_19 main__tmp_21 main__tmp_22
op min progression main__tmp_19 10
set main__tmp_31 progression
op sqrt main__tmp_31 main__tmp_31 0
op mul main__tmp_30 progression 4
op add main__tmp_27 2 main__tmp_30
op mul main__tmp_28 progression 2
op rand main__tmp_28 main__tmp_28 0
op add units main__tmp_27 main__tmp_28
op mul units units 1
op ceil units units 0
set tank_units units
op rand tank_units tank_units 0
op floor tank_units tank_units 0
op sub mech_units units tank_units
op rand mech_units mech_units 0
op floor mech_units mech_units 0
op sub main__tmp_39 units tank_units
op sub air_units main__tmp_39 mech_units
set spawnx 30
set spawny 50
jump spawn_tank always 0 0
spawn_tank_end:
jump spawn_mech always 0 0
spawn_mech_end:
set spawnx 20
jump spawn_air always 0 0
spawn_air_end:
write wave cell1 1
read timeout cell1 0
set main__tmp_48 @time
op mul main__tmp_49 timeout 1000
op add timeout main__tmp_48 main__tmp_49
main_wait:
set main__tmp_53 @time
op sub remaining timeout main__tmp_53
jump main__label_1_endif greaterThan remaining 0
jump main always 0 0
main__label_1_endif:
print "[yellow]Wave "
print wave
print "[white] - "
print "Next wave: "
op div main__tmp_61 remaining 1000
op ceil main__tmp_61 main__tmp_61 0
print main__tmp_61
print " s"
message mission
wait 0.5
jump main_wait always 0 0
spawn_tank:
set spawned 0
spawn_tank_loop:
set roll progression
op rand roll roll 0
jump main__label_2_else lessThan roll 3
jump main__label_4_else lessThan roll 4
set main__tmp_76 @crux
spawn @conquer spawnx spawny 0 main__tmp_76 _
op sub spawnx spawnx 5.75
jump main__label_3_endif always 0 0
main__label_4_else:
set main__tmp_84 @crux
spawn @vanquish spawnx spawny 0 main__tmp_84 _
op sub spawnx spawnx 3.5
jump main__label_3_endif always 0 0
main__label_2_else:
jump main__label_6_else lessThan roll 2
set main__tmp_95 @crux
spawn @precept spawnx spawny 0 main__tmp_95 _
op sub spawnx spawnx 3.25
jump main__label_7_endif always 0 0
main__label_6_else:
jump main__label_8_else lessThan roll 1
set main__tmp_106 @crux
spawn @locus spawnx spawny 0 main__tmp_106 _
op sub spawnx spawnx 1
jump main__label_9_endif always 0 0
main__label_8_else:
set main__tmp_114 @crux
spawn @stell spawnx spawny 0 main__tmp_114 _
op sub spawnx spawnx 1
main__label_9_endif:
main__label_7_endif:
main__label_3_endif:
jump main__label_10_endif greaterThanEqual spawnx 10
set spawnx 10
main__label_10_endif:
op add spawned spawned 1
jump spawn_tank_end greaterThanEqual spawned tank_units
jump spawn_tank_loop always 0 0
jump spawn_mech always 0 0
spawn_mech:
set spawned 0
spawn_mech_loop:
set roll progression
op rand roll roll 0
jump main__label_12_else lessThan roll 3
jump main__label_14_else lessThan roll 4
set main__tmp_136 @crux
spawn @collaris spawnx spawny 0 main__tmp_136 _
op sub spawnx spawnx 5.5
jump main__label_13_endif always 0 0
main__label_14_else:
set main__tmp_144 @crux
spawn @tecta spawnx spawny 0 main__tmp_144 _
op sub spawnx spawnx 2.87
jump main__label_13_endif always 0 0
main__label_12_else:
jump main__label_16_else lessThan roll 2
set main__tmp_155 @crux
spawn @anthicus spawnx spawny 0 main__tmp_155 _
op sub spawnx spawnx 2.62
jump main__label_17_endif always 0 0
main__label_16_else:
jump main__label_18_else lessThan roll 1
set main__tmp_166 @crux
spawn @cleroi spawnx spawny 0 main__tmp_166 _
op sub spawnx spawnx 1
jump main__label_19_endif always 0 0
main__label_18_else:
set main__tmp_174 @crux
spawn @merui spawnx spawny 0 main__tmp_174 _
op sub spawnx spawnx 1
main__label_19_endif:
main__label_17_endif:
main__label_13_endif:
jump main__label_20_endif greaterThanEqual spawnx 10
set spawnx 10
main__label_20_endif:
op add spawned spawned 1
jump spawn_mech_end greaterThanEqual spawned mech_units
jump spawn_mech_loop always 0 0
jump spawn_mech_end always 0 0
spawn_air:
set spawned 0
spawn_air_loop:
set roll progression
op rand roll roll 0
jump main__label_22_else lessThan roll 3
jump main__label_24_else lessThan roll 4
set main__tmp_196 @crux
spawn @disrupt spawnx spawny 0 main__tmp_196 _
op sub spawnx spawnx 5.75
jump main__label_23_endif always 0 0
main__label_24_else:
set main__tmp_204 @crux
spawn @quell spawnx spawny 0 main__tmp_204 _
op sub spawnx spawnx 4.5
jump main__label_23_endif always 0 0
main__label_22_else:
jump main__label_26_else lessThan roll 2
set main__tmp_215 @crux
spawn @obviate spawnx spawny 0 main__tmp_215 _
op sub spawnx spawnx 3.12
jump main__label_27_endif always 0 0
main__label_26_else:
jump main__label_28_else lessThan roll 1
set main__tmp_226 @crux
spawn @avert spawnx spawny 0 main__tmp_226 _
op sub spawnx spawnx 1
jump main__label_29_endif always 0 0
main__label_28_else:
set main__tmp_234 @crux
spawn @elude spawnx spawny 0 main__tmp_234 _
op sub spawnx spawnx 1
main__label_29_endif:
main__label_27_endif:
main__label_23_endif:
jump main__label_30_endif greaterThanEqual spawnx 10
set spawnx 10
main__label_30_endif:
op add spawned spawned 1
jump spawn_air_end greaterThanEqual spawned air_units
jump spawn_air_loop always 0 0
jump spawn_air_end always 0 0
Loading…
Cancel
Save