Refactored remaining tests to use check macro
This commit is contained in:
@@ -9,8 +9,14 @@ fn variable_declaration_numeric_literal() -> anyhow::Result<()> {
|
||||
"#
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -40,8 +46,14 @@ fn variable_declaration_numeric_literal_stack_spillover() -> anyhow::Result<()>
|
||||
let j = 9;
|
||||
"#};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -73,8 +85,14 @@ fn variable_declaration_negative() -> anyhow::Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -97,8 +115,14 @@ fn test_boolean_declaration() -> anyhow::Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -125,8 +149,14 @@ fn test_boolean_return() -> anyhow::Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -149,15 +179,21 @@ fn test_boolean_return() -> anyhow::Result<()> {
|
||||
|
||||
#[test]
|
||||
fn test_const_hash_expr() -> anyhow::Result<()> {
|
||||
let compiled = compile!(debug r#"
|
||||
let compiled = compile!(check r#"
|
||||
const nameHash = hash("AccessCard");
|
||||
device self = "db";
|
||||
|
||||
self.Setting = nameHash;
|
||||
"#);
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -180,8 +216,14 @@ fn test_declaration_is_const() -> anyhow::Result<()> {
|
||||
"#
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
|
||||
@@ -24,8 +24,14 @@ fn device_property_read() -> anyhow::Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -48,8 +54,14 @@ fn device_property_write() -> anyhow::Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -72,6 +84,12 @@ fn multiple_device_declarations() -> anyhow::Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
// Declarations only emit the header when unused
|
||||
assert_eq!(compiled.output, "j main\n");
|
||||
|
||||
@@ -89,8 +107,14 @@ fn device_with_variable_interaction() -> anyhow::Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -116,9 +140,15 @@ fn device_property_in_arithmetic() -> anyhow::Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
// Verify that we load property, add 100, and move to result
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -147,8 +177,14 @@ fn device_used_in_function() -> anyhow::Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -182,8 +218,14 @@ fn device_in_conditional() -> anyhow::Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -208,8 +250,14 @@ fn device_property_with_underscore_name() -> anyhow::Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
|
||||
@@ -447,8 +447,8 @@ fn modulo_operation() -> anyhow::Result<()> {
|
||||
fn exponentiation() -> anyhow::Result<()> {
|
||||
let compiled = compile! {
|
||||
check "
|
||||
let x = 2 ^ 8;
|
||||
let y = 3 ^ 3;
|
||||
let x = 2 ** 8;
|
||||
let y = 3 ** 3;
|
||||
"
|
||||
};
|
||||
|
||||
@@ -464,8 +464,10 @@ fn exponentiation() -> anyhow::Result<()> {
|
||||
"
|
||||
j main
|
||||
main:
|
||||
move r0 3
|
||||
move r1 3
|
||||
pow r1 2 8
|
||||
move r8 r1
|
||||
pow r2 3 3
|
||||
move r9 r2
|
||||
"
|
||||
}
|
||||
);
|
||||
|
||||
@@ -41,8 +41,14 @@ fn test_asin() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -65,8 +71,14 @@ fn test_atan() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -89,8 +101,14 @@ fn test_atan2() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -113,8 +131,14 @@ fn test_abs() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -137,8 +161,14 @@ fn test_ceil() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -161,8 +191,14 @@ fn test_cos() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -185,8 +221,14 @@ fn test_floor() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -209,8 +251,14 @@ fn test_log() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -233,8 +281,14 @@ fn test_max() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -258,8 +312,14 @@ fn test_max_from_game() -> Result<()> {
|
||||
"#
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -283,8 +343,14 @@ fn test_min() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -307,8 +373,14 @@ fn test_rand() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -331,8 +403,14 @@ fn test_sin() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -355,8 +433,14 @@ fn test_sqrt() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -379,8 +463,14 @@ fn test_tan() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
@@ -403,8 +493,14 @@ fn test_trunc() -> Result<()> {
|
||||
"
|
||||
};
|
||||
|
||||
assert!(
|
||||
compiled.errors.is_empty(),
|
||||
"Expected no errors, got: {:?}",
|
||||
compiled.errors
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
compiled,
|
||||
compiled.output,
|
||||
indoc! {
|
||||
"
|
||||
j main
|
||||
|
||||
Reference in New Issue
Block a user