fold nested literal binary expressions
This commit is contained in:
@@ -17,8 +17,7 @@ fn simple_binary_expression() -> anyhow::Result<()> {
|
||||
"
|
||||
j main
|
||||
main:
|
||||
add r1 1 2
|
||||
move r8 r1 #i
|
||||
move r8 3 #i
|
||||
"
|
||||
}
|
||||
);
|
||||
@@ -72,7 +71,7 @@ fn nested_binary_expressions() -> anyhow::Result<()> {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn stress_test_negation_with_stack_spillover() -> anyhow::Result<()> {
|
||||
fn stress_test_constant_folding() -> anyhow::Result<()> {
|
||||
let compiled = compile! {
|
||||
debug
|
||||
"
|
||||
@@ -86,12 +85,7 @@ fn stress_test_negation_with_stack_spillover() -> anyhow::Result<()> {
|
||||
"
|
||||
j main
|
||||
main:
|
||||
add r1 -1 -2
|
||||
add r2 -5 -6
|
||||
mul r3 -4 r2
|
||||
add r4 -3 r3
|
||||
mul r5 r1 r4
|
||||
move r8 r5 #negationHell
|
||||
move r8 -123 #negationHell
|
||||
"
|
||||
}
|
||||
);
|
||||
|
||||
@@ -112,9 +112,8 @@ fn test_math_with_logic() -> anyhow::Result<()> {
|
||||
"
|
||||
j main
|
||||
main:
|
||||
add r1 1 2
|
||||
sgt r2 r1 1
|
||||
move r8 r2 #logic
|
||||
sgt r1 3 1
|
||||
move r8 r1 #logic
|
||||
"
|
||||
}
|
||||
);
|
||||
|
||||
@@ -88,7 +88,7 @@ fn test_set_on_device_batched() -> anyhow::Result<()> {
|
||||
let compiled = compile! {
|
||||
debug
|
||||
r#"
|
||||
let doorHash = hash("Door");
|
||||
const doorHash = hash("Door");
|
||||
setOnDeviceBatched(doorHash, "Lock", true);
|
||||
"#
|
||||
};
|
||||
@@ -99,9 +99,7 @@ fn test_set_on_device_batched() -> anyhow::Result<()> {
|
||||
r#"
|
||||
j main
|
||||
main:
|
||||
move r15 HASH("Door") #hash_ret
|
||||
move r8 r15 #doorHash
|
||||
sb r8 Lock 1
|
||||
sb 718797587 Lock 1
|
||||
"#
|
||||
}
|
||||
);
|
||||
@@ -133,27 +131,3 @@ fn test_load_from_device() -> anyhow::Result<()> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_hash() -> anyhow::Result<()> {
|
||||
let compiled = compile! {
|
||||
debug
|
||||
r#"
|
||||
let nameHash = hash("testValue");
|
||||
"#
|
||||
};
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
indoc! {
|
||||
r#"
|
||||
j main
|
||||
main:
|
||||
move r15 HASH("testValue") #hash_ret
|
||||
move r8 r15 #nameHash
|
||||
"#
|
||||
}
|
||||
);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user