Allow to trace expressions (and not only string literals)

This however enforces that the argument unifies to a `String`. So this
  is more flexible than the previous form, but does fundamentally the
  same thing.

  Fixes #378.
This commit is contained in:
KtorZ
2023-02-15 18:46:07 +01:00
parent 4e51e49fe6
commit 7abd76b6ad
10 changed files with 185 additions and 42 deletions

View File

@@ -126,3 +126,35 @@ fn list_pattern_6() {
"#;
assert!(check(parse(source_code)).is_ok())
}
#[test]
fn trace_strings() {
let source_code = r#"
fn bar() {
"BAR"
}
test foo() {
let msg1 = "FOO"
trace("INLINE")
trace(msg1)
trace(bar())
True
}
"#;
assert!(check(parse(source_code)).is_ok())
}
#[test]
fn trace_non_strings() {
let source_code = r#"
test foo() {
trace(14 + 42)
True
}
"#;
assert!(matches!(
check(parse(source_code)),
Err((_, Error::CouldNotUnify { .. }))
))
}