From e0bf5bf5e40df9d0a376bfdf7fba85e2e4ee4da8 Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Wed, 6 Nov 2019 20:00:52 +0100 Subject: [PATCH] added tests for the changes --- src/compiler.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/compiler.rs b/src/compiler.rs index da00f94..704d2f4 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -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] @@ -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"