-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for E-expressions using simple system macros. (#100)
- Loading branch information
1 parent
353608a
commit 67a66d5
Showing
3 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Inlining of multiple return values into E-expression arguments. | ||
|
||
|
||
(ion_1_1 "Results of nested E-expressions are inlined into rest arguments" | ||
(each (toplevel ('#$:make_list' 1 2 ('#$:values') 3 4)) | ||
(toplevel ('#$:make_list' 1 ('#$:values' 2 3) 4)) | ||
(toplevel ('#$:make_list' ('#$:values' 1 2 3 4))) | ||
(produces [1, 2, 3, 4])) | ||
(each (toplevel ('#$:make_sexp' 1 2 ('#$:values') 3 4)) | ||
(toplevel ('#$:make_sexp' 1 ('#$:values' 2 3) 4)) | ||
(toplevel ('#$:make_sexp' ('#$:values' 1 2 3 4))) | ||
(produces (1 2 3 4)))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
|
||
// void | ||
|
||
(ion_1_1 | ||
(each (toplevel 1 ('#$:$ion:void') 2) | ||
(toplevel 1 ('#$:$ion:0') 2) | ||
(toplevel 1 ('#$:void') 2) | ||
(produces 1 2))) | ||
|
||
// TODO should this stay true? | ||
(ion_1_1 | ||
(toplevel 1 ('#$:$ion:void' true ('#$:void' false)) 2) | ||
(produces 1 2)) | ||
|
||
|
||
// values | ||
|
||
(ion_1_1 | ||
(each (toplevel 1 ('#$:$ion:values') 2) | ||
(toplevel 1 ('#$:$ion:1') 2) | ||
(toplevel 1 ('#$:values') 2) | ||
(produces 1 2)) | ||
(each (toplevel 1 ('#$:$ion:values' a) 2) | ||
(toplevel 1 ('#$:$ion:1' a) 2) | ||
(toplevel 1 ('#$:values' a) 2) | ||
(produces 1 a 2)) | ||
(each (toplevel 1 ('#$:$ion:values' a b) 2) | ||
(toplevel 1 ('#$:$ion:1' a b) 2) | ||
(toplevel 1 ('#$:values' a b) 2) | ||
(produces 1 a b 2))) | ||
|
||
|
||
// make_string | ||
|
||
// TODO Error when argument isn't text | ||
|
||
(ion_1_1 | ||
(each (toplevel ('#$:make_string')) | ||
(toplevel ('#$:make_string' "")) | ||
(toplevel ('#$:make_string' '')) | ||
(produces "")) | ||
// accepts both strings and symbols | ||
(each (toplevel ('#$:make_string' "a" "b")) | ||
(toplevel ('#$:make_string' a b )) | ||
(toplevel ('#$:make_string' "a" b )) | ||
(toplevel ('#$:make_string' a "b")) | ||
(produces "ab")) | ||
// null.string and null.symbol act like "" | ||
(each (toplevel ('#$:make_string' null.string "ab" null.symbol "")) | ||
(toplevel ('#$:make_string' "a" null.string 'b' null.symbol)) | ||
(toplevel ('#$:make_string' null.symbol "a" null.string "b")) | ||
(produces "ab"))) | ||
|
||
|
||
// make_symbol | ||
|
||
// TODO Error when argument isn't text | ||
|
||
(ion_1_1 | ||
(each (toplevel ('#$:make_symbol')) | ||
(toplevel ('#$:make_symbol' "")) | ||
(toplevel ('#$:make_symbol' '')) | ||
(produces '')) | ||
// accepts both strings and symbols | ||
(each (toplevel ('#$:make_symbol' "a" "b")) | ||
(toplevel ('#$:make_symbol' a b )) | ||
(toplevel ('#$:make_symbol' "a" b )) | ||
(toplevel ('#$:make_symbol' a "b")) | ||
(produces 'ab')) | ||
// null.string and null.symbol act like "" | ||
(each (toplevel ('#$:make_symbol' null.string "ab" null.symbol "")) | ||
(toplevel ('#$:make_symbol' "a" null.string 'b' null.symbol)) | ||
(toplevel ('#$:make_symbol' null.symbol "a" null.string "b")) | ||
(produces 'ab'))) | ||
|
||
|
||
// make_list | ||
|
||
(ion_1_1 | ||
(toplevel ('#$:$ion:make_list') ('#$:$ion:make_list' 1 2)) | ||
(produces [] [1, 2])) | ||
|
||
|
||
// make_sexp | ||
|
||
(ion_1_1 | ||
(toplevel ('#$:$ion:make_sexp') ('#$:$ion:make_sexp' 1 2)) | ||
(produces () (1 2))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Inlining of multiple return values into container elements. | ||
|
||
|
||
(ion_1_1 | ||
(each (toplevel [1, 2, ('#$:values'), 3, 4]) | ||
(toplevel [1, ('#$:values' 2), ('#$:values' 3), 4]) | ||
(toplevel [1, ('#$:values' 2 3), 4]) | ||
(toplevel [('#$:values' 1 2 3 4)]) | ||
(produces [1, 2, 3, 4])) | ||
(each (toplevel (1 2 ('#$:values') 3 4)) | ||
(toplevel (1 ('#$:values' 2) ('#$:values' 3) 4)) | ||
(toplevel (1 ('#$:values' 2 3) 4)) | ||
(toplevel ( ('#$:values' 1 2 3 4) )) | ||
(produces (1 2 3 4)))) | ||
|
||
// TODO Inlining into structs. | ||
// We don't have a way for `toplevel` to express things like { (:foo) } |