From 67a66d53d6575f4332f1c6b78ad89d1f234494e2 Mon Sep 17 00:00:00 2001 From: "Todd V. Jonker" Date: Thu, 13 Jun 2024 10:44:04 -0700 Subject: [PATCH] Add tests for E-expressions using simple system macros. (#100) --- conformance/eexp/arg_inlining.ion | 15 ++++ conformance/eexp/basic_system_macros.ion | 91 ++++++++++++++++++++++++ conformance/eexp/element_inlining.ion | 20 ++++++ 3 files changed, 126 insertions(+) create mode 100644 conformance/eexp/arg_inlining.ion create mode 100644 conformance/eexp/basic_system_macros.ion create mode 100644 conformance/eexp/element_inlining.ion diff --git a/conformance/eexp/arg_inlining.ion b/conformance/eexp/arg_inlining.ion new file mode 100644 index 0000000..095c40c --- /dev/null +++ b/conformance/eexp/arg_inlining.ion @@ -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)))) diff --git a/conformance/eexp/basic_system_macros.ion b/conformance/eexp/basic_system_macros.ion new file mode 100644 index 0000000..5cd6176 --- /dev/null +++ b/conformance/eexp/basic_system_macros.ion @@ -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))) diff --git a/conformance/eexp/element_inlining.ion b/conformance/eexp/element_inlining.ion new file mode 100644 index 0000000..bb8956c --- /dev/null +++ b/conformance/eexp/element_inlining.ion @@ -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) }