Skip to content

Commit

Permalink
added tests for the changes
Browse files Browse the repository at this point in the history
  • Loading branch information
WeirdConstructor committed Nov 6, 2019
1 parent 8221da1 commit e0bf5bf
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,10 @@ mod tests {
assert_eq!(s_eval("\"foobar\" $q/xyz/"), "\"foobarxyz\"");
assert_eq!(s_eval("\"foobar\" ${ foobar = 12 }"), "12");
assert_eq!(s_eval("\"foobar\" ${ (\"foobar\") = 12 }"), "12");
assert_eq!(s_eval("\"foobar\" 2 -1"), "\"obar\"");
assert_eq!(s_eval("\"\" 2 -1"), "\"\"");
assert_eq!(s_eval("\"foobar\" 6 -1"), "\"\"");
assert_eq!(s_eval("\"foobar\" 6"), "\"\"");
}

#[test]
Expand Down Expand Up @@ -2848,6 +2852,19 @@ mod tests {
assert_eq!(s_eval("(std:hash:fnv1a \"http://www.isthe.com/chongo/tech/math/prime/mersenne.html#largest\") - 0x8e87d7e7472b3883"), "0");
}

#[test]
fn string_map_with_function() {
assert_eq!(s_eval("$q$abcdef$ { _ }"), "$[\"a\",\"b\",\"c\",\"d\",\"e\",\"f\"]");
assert_eq!(s_eval("$b\"abcdef\" { _ }"), "$[$b\"a\",$b\"b\",$b\"c\",$b\"d\",$b\"e\",$b\"f\"]");
}

#[test]
fn map_over_map() {
assert_eq!(s_eval(
"!sum = $&0; ${a=10, b=20, c=30} {|2| .sum = sum + _; }; $*sum"),
"60");
}

#[test]
fn check_splitmix64() {
assert_eq!(s_eval(r"
Expand Down

0 comments on commit e0bf5bf

Please sign in to comment.