Skip to content

Commit

Permalink
Add tests for E-expressions using simple system macros. (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
toddjonker authored Jun 13, 2024
1 parent 353608a commit 67a66d5
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 0 deletions.
15 changes: 15 additions & 0 deletions conformance/eexp/arg_inlining.ion
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))))
91 changes: 91 additions & 0 deletions conformance/eexp/basic_system_macros.ion
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)))
20 changes: 20 additions & 0 deletions conformance/eexp/element_inlining.ion
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) }

0 comments on commit 67a66d5

Please sign in to comment.