-
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 conformance tests cases for values, none, meta, default, and rep…
…eat (#133)
- Loading branch information
Showing
5 changed files
with
247 additions
and
21 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,10 +1,84 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test Cases: | ||
// default can be invoked using any type of macro reference. | ||
// both arguments may be any expression or expression group | ||
// if the first argument is non-empty | ||
// - `default` produces the first argument as its result | ||
// - the second argument is not expanded | ||
// if the first argument is empty (i.e. none), `default` produces the second argument as its result | ||
(ion_1_1 "default can be invoked" | ||
(each "in text with an unqualified macro name" | ||
(text " (:default 0 1) ") | ||
"in text with an unqualified macro address" | ||
(text " (:23 0 1) ") | ||
"in text with a qualified macro name" | ||
(text " (:$ion::default 0 1) ") | ||
"in text using qualified system macro address 23" | ||
(text " (:$ion::23 0 1) ") | ||
"in binary using system macro address 23" | ||
(binary "EF 17 05 60 61 01") | ||
"in binary with a user macro address" | ||
(binary "17 05 60 61 01") | ||
(produces 0))) | ||
|
||
(ion_1_1 "default produces" | ||
(each "the first argument when the first argument is a single value" | ||
(text " (:default 1 0) ") | ||
"the second argument when the first argument is empty" | ||
(text " (:default (::) 1) ") | ||
(produces 1)) | ||
(then "nothing when both argument are empty" | ||
(text "(:default)") | ||
(produces /*nothing*/))) | ||
|
||
(ion_1_1 "when the first argument is non-empty, the second argument is not expanded" | ||
// none with any argument should signal an error _iff_ it is evaluated | ||
(text "(:default 1 (:none 123))") | ||
(produces 1)) | ||
|
||
(ion_1_1 "the first argument can be" | ||
(then "a single value" | ||
(text "(:default 1 (::))") | ||
(produces 1)) | ||
(then "an empty expression group" | ||
(text "(:default (::) (::))") | ||
(produces /*nothing*/)) | ||
(then "an expression group with a single value" | ||
(text "(:default (:: 1) (::))") | ||
(produces 1)) | ||
(then "an expression group with multiple values" | ||
(text "(:default (:: 1 2 3) (::))") | ||
(produces 1 2 3)) | ||
(then "an expression that produces nothing" | ||
(text "(:default (:values) (::))") | ||
(produces /*nothing*/)) | ||
(then "an expression that produces a single value" | ||
(text "(:default (:values 1) (::))") | ||
(produces 1)) | ||
(then "an expression that produces multiple values" | ||
(text "(:default (:values 1 2 3) (::))") | ||
(produces 1 2 3))) | ||
|
||
(ion_1_1 "the second argument can be" | ||
(then "nothing" | ||
(text "(:default (::))") | ||
(produces /*nothing*/)) | ||
(then "a single value" | ||
(text "(:default (::) 1)") | ||
(produces 1)) | ||
(then "multiple values" | ||
(text "(:default (::) 1 2 3)") | ||
(produces 1 2 3)) | ||
(then "an empty expression group" | ||
(text "(:default (::) (::))") | ||
(produces /*nothing*/)) | ||
(then "an expression group with a single value" | ||
(text "(:default (::) (:: 1))") | ||
(produces 1)) | ||
(then "an expression group with multiple values" | ||
(text "(:default (::) (:: 1 2 3))") | ||
(produces 1 2 3)) | ||
(then "an expression that produces nothing" | ||
(text "(:default (::) (:values))") | ||
(produces /*nothing*/)) | ||
(then "an expression that produces a single value" | ||
(text "(:default (::) (:values 1))") | ||
(produces 1)) | ||
(then "an expression that produces multiple values" | ||
(text "(:default (::) (:values 1 2 3))") | ||
(produces 1 2 3))) |
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,6 +1,39 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test Cases: | ||
// meta can be invoked using any type of macro reference. | ||
// meta has one parameter that accepts zero-to-many argument expressions and always produces nothing | ||
// This covers _all_ happy cases because there are no arguments and there is no output. | ||
(ion_1_1 "meta can be invoked" | ||
(each "in text with an unqualified macro name" | ||
(text " (:meta) ") | ||
"in text with an unqualified macro address" | ||
(text " (:21) ") | ||
"in text with a qualified macro name" | ||
(text " (:$ion::meta) ") | ||
"in text using qualified system macro address 21" | ||
(text " (:$ion::21) ") | ||
"in binary using system macro address 21" | ||
(binary "EF 15 00") | ||
"in binary with a user macro address" | ||
(binary "15 00") | ||
(produces /*nothing*/))) | ||
|
||
(ion_1_1 "meta produces nothing when its argument is" | ||
(each "no values" | ||
(text "(:meta)") | ||
"a single value" | ||
(text "(:meta 0)") | ||
"multiple values" | ||
(text "(:meta 1 2 3)") | ||
"passed an empty expression group" | ||
(text "(:meta (::))") | ||
"passed an expression group with one value" | ||
(text "(:meta (:: 0))") | ||
"passed an expression group with multiple values" | ||
(text "(:meta (:: 1 2 3))") | ||
"passed an expression that produces nothing" | ||
(text "(:meta (:meta))") | ||
"passed an expression that produces one value" | ||
(text "(:meta (:values 0))") | ||
"passed an expression that produces multiple values" | ||
(text "(:meta (:values 1 2 3))") | ||
(produces /*nothing*/))) |
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,6 +1,27 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test Cases: | ||
// none can be invoked using any type of macro reference. | ||
// none accepts no arguments and produces nothing | ||
// This covers _all_ happy cases because there are no arguments and there is no output. | ||
(ion_1_1 "none can be invoked" | ||
(each "in text with an unqualified macro name" | ||
(text " (:none) ") | ||
"in text with an unqualified macro address" | ||
(text " (:0) ") | ||
"in text with a qualified macro name" | ||
(text " (:$ion::none) ") | ||
"in text using qualified system macro address 0" | ||
(text " (:$ion::0) ") | ||
"in binary using system macro address 0" | ||
(binary "EF 00") | ||
"in binary with a user macro address" | ||
(binary "00") | ||
(produces /*nothing*/))) | ||
|
||
(ion_1_1 "none signals an error when" | ||
(each "passed any expression value" | ||
(text "(:none 0)") | ||
"passed an empty expression group" | ||
(text "(:none (::))") | ||
"passed an expression that produces nothing" | ||
(text "(:none (:none))") | ||
(signals "unexpected 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,72 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test Cases: | ||
// repeat can be invoked using any type of macro reference. | ||
// repeat can repeat things the correct number of times | ||
// the number of repetitions must be a single expression that expands to one positive integer (i.e. an integer greater than zero) | ||
// the thing to be repeated must be at least one expression of any type | ||
(ion_1_1 "repeat can be invoked" | ||
(each "in text with an unqualified macro name" | ||
(text ''' (:repeat 1 1) ''') | ||
"in text with an unqualified macro address" | ||
(text ''' (:17 1 1) ''') | ||
"in text with a qualified macro name" | ||
(text ''' (:$ion::repeat 1 1) ''') | ||
"in text with a qualified macro address" | ||
(text ''' (:$ion::17 1 1) ''') | ||
"in binary with a system macro address" | ||
(binary "EF 11 01 61 01 61 01") | ||
"in binary with a user macro address" | ||
(binary "11 01 61 01 61 01") | ||
(produces 1))) | ||
|
||
(ion_1_1 "repeat can produce" | ||
(then "a single expression" | ||
(then "0 times" (text "(:repeat 0 0)") (produces)) | ||
(then "1 times" (text "(:repeat 1 0)") (produces 0)) | ||
(then "2 times" (text "(:repeat 2 0)") (produces 0 0)) | ||
(then "3 times" (text "(:repeat 3 0)") (produces 0 0 0)) | ||
(then "4 times" (text "(:repeat 4 0)") (produces 0 0 0 0)) | ||
(then "5 times" (text "(:repeat 5 0)") (produces 0 0 0 0 0))) | ||
(then "an empty expression group" | ||
(each (text "(:repeat 0 (::))") | ||
(text "(:repeat 1 (::))") | ||
(text "(:repeat 2 (::))") | ||
(text "(:repeat 3 (::))") | ||
(text "(:repeat 4 (::))") | ||
(produces /*nothing*/ ))) | ||
(then "an expression that produces no values" | ||
(each (text "(:repeat 0 (:none))") | ||
(text "(:repeat 1 (:none))") | ||
(text "(:repeat 2 (:none))") | ||
(text "(:repeat 3 (:none))") | ||
(text "(:repeat 4 (:none))") | ||
(produces /*nothing*/ ))) | ||
(then "an expression group with multiple values" | ||
(then "0 times" (text "(:repeat 0 (:: 0 1))") (produces)) | ||
(then "1 times" (text "(:repeat 1 (:: 0 1))") (produces 0 1)) | ||
(then "2 times" (text "(:repeat 2 (:: 0 1))") (produces 0 1 0 1)) | ||
(then "3 times" (text "(:repeat 3 (:: 0 1))") (produces 0 1 0 1 0 1)) | ||
(then "4 times" (text "(:repeat 4 (:: 0 1))") (produces 0 1 0 1 0 1 0 1))) | ||
(then "an expression that produces multiple values" | ||
(then "0 times" (text "(:repeat 0 (:values 0 1))") (produces)) | ||
(then "1 times" (text "(:repeat 1 (:values 0 1))") (produces 0 1)) | ||
(then "2 times" (text "(:repeat 2 (:values 0 1))") (produces 0 1 0 1)) | ||
(then "3 times" (text "(:repeat 3 (:values 0 1))") (produces 0 1 0 1 0 1)) | ||
(then "4 times" (text "(:repeat 4 (:values 0 1))") (produces 0 1 0 1 0 1 0 1))) ) | ||
|
||
(ion_1_1 "repeat will ignore any annotations on the number of repetitions" | ||
(then (text "(:repeat a::1 0)") (produces 0)) | ||
(then (text "(:repeat b::2 0)") (produces 0 0)) | ||
(then (text "(:repeat c::3 0)") (produces 0 0 0)) | ||
(then (text "(:repeat d::4 0)") (produces 0 0 0 0)) | ||
(then (text "(:repeat e::5 0)") (produces 0 0 0 0 0))) | ||
|
||
(ion_1_1 "repeat signals an error when" | ||
(each "the number of repeats is not an integer" | ||
(text "(:repeat 1d0 0)") | ||
(text "(:repeat 1e1 0)") | ||
(text "(:repeat false 0)") | ||
"the number of repeats is multiple values" | ||
(text "(:repeat (:: 1 2) 0)") | ||
"the number of repeats an expression the produces multiple values" | ||
(text "(:repeat (:values 1 2) 0)") | ||
"the number of repeats is negative" | ||
(text "(:repeat -1 0)") | ||
(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,6 +1,40 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test Cases: | ||
// values can be invoked using any type of macro reference. | ||
// values has one parameter that accept zero-to-many arguments and produces its input | ||
(ion_1_1 "values can be invoked" | ||
(each "in text with an unqualified macro name" | ||
(text ''' (:values 0) ''') | ||
"in text with an unqualified macro address" | ||
(text ''' (:1 0) ''') | ||
"in text with a qualified macro name" | ||
(text ''' (:$ion::values 0) ''') | ||
"in text with a qualified macro address" | ||
(text ''' (:$ion::1 0) ''') | ||
"in binary with a system macro address" | ||
(binary "EF 01 01 60") | ||
"in binary with a user macro address" | ||
(binary "01 01 60") | ||
(produces 0))) | ||
|
||
(ion_1_1 "values produces its input when its argument" | ||
(each "is elided" | ||
(text " (:values)") | ||
"is an empty expression group" | ||
(text " (:values (::))") | ||
"is an expression that evaluates to nothing" | ||
(text " (:values (:values))") | ||
(produces /*nothing*/)) | ||
(each "is a single value" | ||
(text " (:values 0)") | ||
"is an expression that evaluates to a single value" | ||
(text " (:values (:values 0))") | ||
"is an expression group with one value" | ||
(text " (:values (:: 0))") | ||
(produces 0)) | ||
(each "is multiple values" | ||
(text " (:values 1 2 3)") | ||
"is a single expression that evaluates to multiple values" | ||
(text " (:values (:values 1 2 3))") | ||
"is an expression containing multiple values" | ||
(text " (:values (:: 1 2 3))") | ||
(produces 1 2 3))) |