diff --git a/examples/filter_loop.ds b/examples/filter_loop.ds deleted file mode 100644 index 8b83fb3..0000000 --- a/examples/filter_loop.ds +++ /dev/null @@ -1,3 +0,0 @@ -filter item in (from_json (read 'examples/assets/jq_data.json')) { - (length item.commit.committer.name) <= 10 -} diff --git a/examples/find_loop.ds b/examples/find_loop.ds deleted file mode 100644 index f13733b..0000000 --- a/examples/find_loop.ds +++ /dev/null @@ -1,7 +0,0 @@ -list = [1 2 1 3] - -found = find i in list { - i == 3 -} - -(assert_equal 3 found) diff --git a/examples/jq_data.ds b/examples/jq_data.ds index f9c2586..94aeca7 100644 --- a/examples/jq_data.ds +++ b/examples/jq_data.ds @@ -1,8 +1,12 @@ data = (from_json (read 'examples/assets/jq_data.json')) -transform commit_data in data { - { +new_data = []; + +for commit_data in data { + new_data += ( message = commit_data.commit.message name = commit_data.commit.committer.name - } + ) } + +new_data diff --git a/examples/map.ds b/examples/map.ds index f759ce6..b6ddf78 100644 --- a/examples/map.ds +++ b/examples/map.ds @@ -1,7 +1,7 @@ -dictionary = { +dictionary = ( dust = "awesome" answer = 42 -} +) (output 'Dust is ' diff --git a/examples/remove_loop.ds b/examples/remove_loop.ds deleted file mode 100644 index 9362dc9..0000000 --- a/examples/remove_loop.ds +++ /dev/null @@ -1,8 +0,0 @@ -list = [1 2 1 3] - -removed = remove i from list { - i == 3 -} - -(assert_equal 3 removed) -(assert_equal [1 2 1] list) diff --git a/examples/transform_loop.ds b/examples/transform_loop.ds deleted file mode 100644 index 00cdfa9..0000000 --- a/examples/transform_loop.ds +++ /dev/null @@ -1,5 +0,0 @@ -data = (from_json (read "examples/assets/jq_data.json")) - -transform item in data { - item:commit:committer:name -} diff --git a/examples/yield.ds b/examples/yield.ds index 3f21944..1207769 100644 --- a/examples/yield.ds +++ b/examples/yield.ds @@ -1,9 +1,13 @@ 1 -> (output) add_one = |list| => { - transform number in list { - number + 1 + new_list = [] + + for number in list { + new_list += number + 1 } + + new_list } foo = [1, 2, 3] -> (add_one) diff --git a/src/abstract_tree/index.rs b/src/abstract_tree/index.rs index 4093f5e..193dfe7 100644 --- a/src/abstract_tree/index.rs +++ b/src/abstract_tree/index.rs @@ -89,7 +89,7 @@ mod tests { #[test] fn evaluate_map_index() { - let test = evaluate("x = {y = {z = 2}} x:y:z").unwrap(); + let test = evaluate("x = (y = (z = 2)) x:y:z").unwrap(); assert_eq!(Value::Integer(2), test); } diff --git a/src/evaluator.rs b/src/evaluator.rs index 5249c6c..6f4dea4 100644 --- a/src/evaluator.rs +++ b/src/evaluator.rs @@ -164,7 +164,7 @@ mod tests { variables.insert("foo".to_string(), Value::String("bar".to_string())); } - assert_eq!(evaluate("{ x = 1, foo = 'bar' }"), Ok(Value::Map(map))); + assert_eq!(evaluate("( x = 1, foo = 'bar' )"), Ok(Value::Map(map))); } #[test] diff --git a/tests/dust_examples.rs b/tests/dust_examples.rs index 45fea80..c847f72 100644 --- a/tests/dust_examples.rs +++ b/tests/dust_examples.rs @@ -39,20 +39,6 @@ fn fibonacci() { evaluate(&file_contents).unwrap(); } -#[test] -fn filter_loop() { - let file_contents = read_to_string("examples/filter_loop.ds").unwrap(); - - evaluate(&file_contents).unwrap(); -} - -#[test] -fn find_loop() { - let file_contents = read_to_string("examples/find_loop.ds").unwrap(); - - evaluate(&file_contents).unwrap(); -} - #[test] fn fizzbuzz() { let file_contents = read_to_string("examples/fizzbuzz.ds").unwrap(); @@ -102,13 +88,6 @@ fn random() { evaluate(&file_contents).unwrap(); } -#[test] -fn remove_loop() { - let file_contents = read_to_string("examples/remove_loop.ds").unwrap(); - - evaluate(&file_contents).unwrap(); -} - #[test] fn sea_creatures() { let file_contents = read_to_string("examples/sea_creatures.ds").unwrap(); @@ -130,13 +109,6 @@ fn table() { evaluate(&file_contents).unwrap(); } -#[test] -fn transform_loop() { - let file_contents = read_to_string("examples/transform_loop.ds").unwrap(); - - evaluate(&file_contents).unwrap(); -} - #[test] fn variables() { let file_contents = read_to_string("examples/variables.ds").unwrap();