-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds tests cases for make_* system macros (#135)
- Loading branch information
Showing
8 changed files
with
745 additions
and
57 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 |
---|---|---|
@@ -1,9 +1,64 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test Cases: | ||
// make_decimal can be invoked using any type of macro reference. | ||
// make_decimal creates a single unannotated decimal | ||
// the coefficient argument must be a non-null integer | ||
// the exponent argument must be a non-null integer | ||
// annotations on the argument values are silently dropped | ||
(ion_1_1 "make_decimal can be invoked" | ||
(each "in text with an unqualified macro name" | ||
(text " (:make_decimal 0 0) ") | ||
"in text with an unqualified macro address" | ||
(text " (:6 0 0) ") | ||
"in text with a qualified macro name" | ||
(text " (:$ion::make_decimal 0 0) ") | ||
"in text using qualified system macro address 6" | ||
(text " (:$ion::6 0 0) ") | ||
"in binary using system macro address 6" | ||
(binary "EF 06 01 01") | ||
"in binary with a user macro address" | ||
(binary "06 01 01") | ||
(produces 0.))) | ||
|
||
(ion_1_1 "the first argument must be a single, non-null integer" | ||
(each (text " (:make_decimal null 0) ") | ||
(text " (:make_decimal null.int 0) ") | ||
(text " (:make_decimal 0e0 0) ") | ||
(text " (:make_decimal 0d0 0) ") | ||
(text " (:make_decimal (:none) 0) ") | ||
(text " (:make_decimal (:: 1 2) 0) ") | ||
(signals "invalid argument"))) | ||
|
||
(ion_1_1 "the second argument must be a single, non-null integer" | ||
(each (text " (:make_decimal 0 null) ") | ||
(text " (:make_decimal 0 null.int) ") | ||
(text " (:make_decimal 0 0e0) ") | ||
(text " (:make_decimal 0 0d0) ") | ||
(text " (:make_decimal 0 (:none)) ") | ||
(text " (:make_decimal 0 (:: 1 2)) ") | ||
(signals "invalid argument"))) | ||
|
||
(ion_1_1 "in binary both arguments are encoded as flex_int" | ||
(then (binary "EF 06 01 01 ") (produces 0d0)) | ||
(then (binary "EF 06 03 03 ") (produces 1d1)) | ||
(then (binary "EF 06 06 00 06 00") (produces 1d1)) | ||
(then (binary "EF 06 9E F4 01 ") (produces -729d0)) | ||
(then (binary "EF 06 01 9E F4") (produces 0d-729)) | ||
(then (binary "EF 06 FF FF ") (produces -1d-1)) | ||
(then (binary "EF 06 FE FF FE FF") (produces -1d-1))) | ||
|
||
(ion_1_1 "make_decimal creates a single unannotated decimal" | ||
(then (text "(:make_decimal -3 1)") (produces -3d1)) | ||
(then (text "(:make_decimal -2 1)") (produces -2d1)) | ||
(then (text "(:make_decimal -1 1)") (produces -1d1)) | ||
(then (text "(:make_decimal -0 1)") (produces 0d1)) | ||
(then (text "(:make_decimal 0 1)") (produces 0d1)) | ||
(then (text "(:make_decimal 1 1)") (produces 1d1)) | ||
(then (text "(:make_decimal 2 1)") (produces 2d1)) | ||
(then (text "(:make_decimal 3 1)") (produces 3d1)) | ||
(then (text "(:make_decimal 2 -3)") (produces 2d-3)) | ||
(then (text "(:make_decimal 2 -2)") (produces 2d-2)) | ||
(then (text "(:make_decimal 2 -1)") (produces 2d-1)) | ||
(then (text "(:make_decimal 2 -0)") (produces 2d0)) | ||
(then (text "(:make_decimal 2 0)") (produces 2d0)) | ||
(then (text "(:make_decimal 2 1)") (produces 2d1)) | ||
(then (text "(:make_decimal 2 2)") (produces 2d2)) | ||
(then (text "(:make_decimal 2 3)") (produces 2d3)) | ||
// Argument annotations are silently dropped. | ||
(then (text "(:make_decimal a::3 b::3)") (produces 3d3))) |
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 |
---|---|---|
@@ -1,10 +1,68 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test Cases: | ||
// make_field can be invoked using any type of macro reference. | ||
// the first argument must expand to a single non-null text value (`$0` is allowed) | ||
// annotations first argument are silently dropped | ||
// the second argument may be any single expression that expands to a single expression | ||
// make_field expands to a single unannotated struct containing only field(s) with the first argument as the field name, | ||
// and the second argument value as the field value. | ||
(ion_1_1 "make_field can be invoked" | ||
(each "in text with an unqualified macro name" | ||
(text " (:make_field foo 0) ") | ||
"in text with an unqualified macro address" | ||
(text " (:22 foo 0) ") | ||
"in text with a qualified macro name" | ||
(text " (:$ion::make_field foo 0) ") | ||
"in text using qualified system macro address 22" | ||
(text " (:$ion::22 foo 0) ") | ||
"in binary using system macro address 22" | ||
(binary "EF 16 FB 66 6F 6F 60") | ||
"in binary with a user macro address" | ||
(binary "16 FB 66 6F 6F 60") | ||
(produces {foo: 0} ))) | ||
|
||
(ion_1_1 "the first argument" | ||
(then "can be" | ||
(each "a string" | ||
(text ''' (:make_field "foo" 0) ''') | ||
"a symbol with known text" | ||
(text "(:make_field foo 0)") | ||
"an expression that produces text" | ||
(text "(:make_field (:values 'foo') 0)") | ||
"annotated" | ||
(text "(:make_field bar::foo 0)") | ||
(produces {foo:0} )) | ||
(then "a symbol with unknown text" | ||
(text "(:make_field $0 1)") | ||
// Could be (produces {$0:1} ), but some implementations don't support $0 nicely. | ||
(denotes (Struct (0 1))))) | ||
(then "cannot be" | ||
(each "null" | ||
(text "(:make_field null 0)") | ||
"a null symbol" | ||
(text "(:make_field null.symbol 0)") | ||
"a null string" | ||
(text "(:make_field null.string 0)") | ||
"a non-text value" | ||
(text "(:make_field 123 0)") | ||
"empty expression group" | ||
(text "(:make_field (::) 0)") | ||
"nothing" | ||
(text "(:make_field (:none) 0)") | ||
(signals "invalid argument")))) | ||
|
||
(ion_1_1 "the second argument" | ||
(then "can be" | ||
(then "a single value" | ||
(text "(:make_field foo 0)") | ||
(produces {foo:0} )) | ||
(then "an expression that produces a single value" | ||
(text "(:make_field foo (:values foo))") | ||
(produces {foo:0} ))) | ||
(then "cannot be" | ||
(each "missing" | ||
(text "(:make_field foo)") | ||
"an empty expression group" | ||
(text "(:make_field foo (::))") | ||
"an expression that produces no values" | ||
(text "(:make_field foo (:none))") | ||
"an expression that produces multiple values" | ||
(text "(:make_field foo (:values 1 2 3))") | ||
"an expression group with multiple values" | ||
(text "(:make_field foo (:: 1 2 3))") | ||
(signals "invalid argument")))) |
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 |
---|---|---|
@@ -1,8 +1,62 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test Cases: | ||
// make_list can be invoked using any type of macro reference. | ||
// the argument values may be zero or more non-null lists and s-expressions | ||
// make_list creates a single unannotated list whose elements are the concatenated elements of all its arguments | ||
// annotations on the argument values are silently dropped | ||
(ion_1_1 "make_list can be invoked" | ||
(each "in text with an unqualified macro name" | ||
(text " (:make_list (::)) ") | ||
"in text with an unqualified macro address" | ||
(text " (:8 (::)) ") | ||
"in text with a qualified macro name" | ||
(text " (:$ion::make_list (::)) ") | ||
"in text using qualified system macro address 8" | ||
(text " (:$ion::8 (::)) ") | ||
"in binary using system macro address 8" | ||
(binary "EF 08 00") | ||
"in binary with a user macro address" | ||
(binary "08 00") | ||
(produces []))) | ||
|
||
(ion_1_1 "make_list creates a single, unannotated list from" | ||
(then "0 values" | ||
(text "(:make_list)") | ||
(produces [])) | ||
(each "one list" | ||
(text "(:make_list [1, 2, 3])") | ||
"multiple lists" | ||
(text "(:make_list [1, 2] [3])") | ||
(text "(:make_list [1] [2] [3])") | ||
(text "(:make_list [] [1, 2, 3] [])") | ||
(text "(:make_list [] [1] [] [2] [] [3] [])") | ||
"one sexp" | ||
(text "(:make_list (1 2 3))") | ||
"multiple sexps" | ||
(text "(:make_list (1 2) (3))") | ||
(text "(:make_list (1) (2) (3))") | ||
(text "(:make_list () (1 2 3) ())") | ||
(text "(:make_list () (1) () (2) () (3) ())") | ||
"a mix of lists and sexps" | ||
(text "(:make_list () [1] (2) [3])") | ||
(text "(:make_list (1) [2, 3] ())") | ||
"annotated sequence values" | ||
// Argument annotations are silently dropped. | ||
(text "(:make_list a::() b::[1] c::(2) d::[3])") | ||
(produces [1, 2, 3]))) | ||
|
||
(ion_1_1 "the argument cannot be" | ||
(each "null" | ||
(text "(:make_list null)") | ||
(text "(:make_list [1] null [2])") | ||
"null.list" | ||
(text "(:make_list null.list)") | ||
(text "(:make_list [1] null.list [2])") | ||
"null.sexp" | ||
(text "(:make_list null.sexp)") | ||
(text "(:make_list [1] null.sexp [2])") | ||
"a non-sequence value" | ||
(text "(:make_list {{ '''abc''' }})") | ||
(text "(:make_list [1] {{ '''abc''' }} [2])") | ||
(text "(:make_list 123)") | ||
(text "(:make_list [1] 123 [2])") | ||
(text "(:make_list { a: 1 })") | ||
(text "(:make_list [1] { a: 1 } [2])") | ||
(signals "invalid argument"))) |
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 |
---|---|---|
@@ -1,8 +1,62 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test Cases: | ||
// make_sexp can be invoked using any type of macro reference. | ||
// the argument values may be zero or more non-null lists and s-expressions | ||
// make_sexp creates a single unannotated s-expression whose elements are the concatenated elements of all its arguments | ||
// annotations on the argument values are silently dropped | ||
(ion_1_1 "make_sexp can be invoked" | ||
(each "in text with an unqualified macro name" | ||
(text " (:make_sexp (::)) ") | ||
"in text with an unqualified macro address" | ||
(text " (:9 (::)) ") | ||
"in text with a qualified macro name" | ||
(text " (:$ion::make_sexp (::)) ") | ||
"in text using qualified system macro address 9" | ||
(text " (:$ion::9 (::)) ") | ||
"in binary using system macro address 9" | ||
(binary "EF 09 00") | ||
"in binary with a user macro address" | ||
(binary "09 00") | ||
(produces ()))) | ||
|
||
(ion_1_1 "make_sexp creates a single, unannotated sexp from" | ||
(then "0 values" | ||
(text "(:make_sexp)") | ||
(produces ())) | ||
(each "one list" | ||
(text "(:make_sexp [1, 2, 3])") | ||
"multiple lists" | ||
(text "(:make_sexp [1, 2] [3])") | ||
(text "(:make_sexp [1] [2] [3])") | ||
(text "(:make_sexp [] [1, 2, 3] [])") | ||
(text "(:make_sexp [] [1] [] [2] [] [3] [])") | ||
"one sexp" | ||
(text "(:make_sexp (1 2 3))") | ||
"multiple sexps" | ||
(text "(:make_sexp (1 2) (3))") | ||
(text "(:make_sexp (1) (2) (3))") | ||
(text "(:make_sexp () (1 2 3) ())") | ||
(text "(:make_sexp () (1) () (2) () (3) ())") | ||
"a mix of lists and sexps" | ||
(text "(:make_sexp () [1] (2) [3])") | ||
(text "(:make_sexp (1) [2, 3] ())") | ||
"annotated sequence values" | ||
// Argument annotations are silently dropped. | ||
(text "(:make_sexp a::() b::[1] c::(2) d::[3])") | ||
(produces (1 2 3)))) | ||
|
||
(ion_1_1 "the argument cannot be" | ||
(each "null" | ||
(text "(:make_sexp null)") | ||
(text "(:make_sexp (1) null (2))") | ||
"null.list" | ||
(text "(:make_sexp null.list)") | ||
(text "(:make_sexp (1) null.list (2))") | ||
"null.sexp" | ||
(text "(:make_sexp null.sexp)") | ||
(text "(:make_sexp (1) null.sexp (2))") | ||
"a non-sequence value" | ||
(text "(:make_sexp {{ '''abc''' }})") | ||
(text "(:make_sexp (1) {{ '''abc''' }} (2))") | ||
(text "(:make_sexp 123)") | ||
(text "(:make_sexp (1) 123 (2))") | ||
(text "(:make_sexp { a: 1 })") | ||
(text "(:make_sexp (1) { a: 1 } (2))") | ||
(signals "invalid argument"))) |
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 |
---|---|---|
@@ -1,8 +1,74 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test Cases: | ||
// make_string can be invoked using any type of macro reference. | ||
// make_string creates a single unannotated string from zero or more text values | ||
// null values, unknown symbol text, and non-text values must signal an error | ||
// annotations on the argment values are silently dropped | ||
(ion_1_1 "make_string can be invoked" | ||
(each "in text with an unqualified macro name" | ||
(text " (:make_string (::)) ") | ||
"in text with an unqualified macro address" | ||
(text " (:3 (::)) ") | ||
"in text with a qualified macro name" | ||
(text " (:$ion::make_string (::)) ") | ||
"in text using qualified system macro address 3" | ||
(text " (:$ion::3 (::)) ") | ||
"in binary using system macro address 3" | ||
(binary "EF 03 00") | ||
"in binary with a user macro address" | ||
(binary "03 00") | ||
(produces ""))) | ||
|
||
(ion_1_1 "make_string creates a single, unannotated string from" | ||
(then "0 values" | ||
(text ''' (:make_string) ''') | ||
(produces "")) | ||
(then "1 string" | ||
(text ''' (:make_string "a") ''') | ||
(produces "a")) | ||
(then "2 strings" | ||
(text ''' (:make_string "a" "b") ''') | ||
(produces "ab")) | ||
(then "3 strings" | ||
(text ''' (:make_string "a" "b" "c") ''') | ||
(produces "abc")) | ||
(then "1 symbol" | ||
(text ''' (:make_string a) ''') | ||
(produces "a")) | ||
(then "2 symbols" | ||
(text ''' (:make_string a b) ''') | ||
(produces "ab")) | ||
(then "3 symbols" | ||
(text ''' (:make_string a b c) ''') | ||
(produces "abc")) | ||
(then "a mix of strings and symbols" | ||
(text ''' (:make_string a "b" c "d") ''') | ||
(produces "abcd")) | ||
(then "an expression that produces multiple text values" | ||
(text ''' (:make_string (:values a "b" c)) ''') | ||
(produces "abc")) | ||
(then "annotated text values" | ||
// Argument annotations are silently dropped. | ||
(text ''' (:make_string x::a y::"b" z::c) ''') | ||
(produces "abc"))) | ||
|
||
(ion_1_1 "the argument cannot be" | ||
(each "null" | ||
(text ''' (:make_string null) ''') | ||
(text ''' (:make_string "a" null "b") ''') | ||
"null.string" | ||
(text ''' (:make_string null.string) ''') | ||
(text ''' (:make_string "a" null.string "b") ''') | ||
"null.symbol" | ||
(text ''' (:make_string null.symbol) ''') | ||
(text ''' (:make_string "a" null.symbol "b") ''') | ||
"a non-text value" | ||
(text ''' (:make_string {{ "abc" }}) ''') | ||
(text ''' (:make_string 123) ''') | ||
(text ''' (:make_string ["a", "b", "c"]) ''') | ||
(text ''' (:make_string "a" {{ "abc" }} "b") ''') | ||
(text ''' (:make_string "a" 123 "b") ''') | ||
(text ''' (:make_string "a" ["a", "b", "c"] "b") ''') | ||
"a symbol with unknown text" | ||
(text ''' (:make_string $0) ''') | ||
(text ''' (:make_string "a" $0 "b") ''') | ||
(text ''' (:make_string $9999999) ''') | ||
(text ''' (:make_string "a" $9999999 "b") ''') | ||
(signals "invalid argument"))) |
Oops, something went wrong.