-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds test cases for add/set_symbols and add/set_macros #136
Changes from all commits
15811a1
852f8ce
17b8727
865e5d6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,87 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test Cases: | ||
// add_macros can be invoked using any type of macro reference. | ||
// the argument values may be zero or more macro definitions | ||
// add_macros does not have any side-effects on the symbol table | ||
// add_macros should append its arguments to the macro table of the default module | ||
// annotations on any argument value should signal an error (because it's not allowed in the macro table rather than because of any specific validation by the add_macros macro) | ||
// TODO: add_macros can accept a module name (of a loaded module) as an argument? | ||
// TODO: add_macros can accept a module/macro export? | ||
|
||
(ion_1_1 "add_macros can be invoked" | ||
(each "in text with an unqualified macro name" | ||
(text "(:add_macros) ") | ||
"in text with an unqualified macro address" | ||
(text "(:14)") | ||
"in text with a qualified macro name" | ||
(text "(:$ion::add_macros)") | ||
"in text with a qualified macro address 14" | ||
(text "(:$ion::14)") | ||
"in binary with a system macro address 14" | ||
(binary "EF 0E 00") | ||
"in binary with a user macro address" | ||
(binary "0E 00") | ||
(produces))) | ||
|
||
(ion_1_1 "add_macros can add a macro to the macro table" | ||
(text "(:add_macros (macro x () X))") | ||
(each "and it can be invoked by name" | ||
(text "(:x)") | ||
"and it can be invoked by address" | ||
(text "(:0)") | ||
(produces X)) | ||
(then "then add_macros can accept" | ||
(then "an empty expression group" | ||
(text "(:add_macros (::))") | ||
(then "with no error and producing no user values" | ||
(produces)) | ||
(then "and does not remove any macros" | ||
(text "(:x)") | ||
(produces X))) | ||
(then "a single macro" | ||
(text "(:add_macros (macro foo () 123))") | ||
(then "with no error and producing no user values" | ||
(produces)) | ||
(then "and does not remove any macros" | ||
(text "(:x)") | ||
(produces X)) | ||
(each "and appends the new macro to the macro table" | ||
(text "(:foo)") | ||
(text "(:1)") | ||
(produces 123))) | ||
(then "multiple macros" | ||
(text '''(:add_macros (macro foo () 123) | ||
(macro null () 456) | ||
(macro bar () 789))''') | ||
(then "with no error and producing no user values" | ||
(produces)) | ||
(then "and does not remove any macros" | ||
(text "(:x)") | ||
(produces X)) | ||
(each "and appends the new macros to the macro table" | ||
(text "(:foo) (:2) (:bar)") | ||
(text "(:1) (:2) (:3)") | ||
(produces 123 456 789))))) | ||
|
||
(ion_1_1 "add_macros does not accept" | ||
(each "nulls" | ||
(text "(:add_macros null)") | ||
(text "(:add_macros null.symbol)") | ||
(text "(:add_macros null.sexp)") | ||
"invalid macro definitions" | ||
(text "(:add_macros a::(macro foo () 123))") | ||
(text "(:add_macros (macro $0 () 123))") | ||
(text "(:add_macros ( foo () 123))") | ||
(text "(:add_macros (macro () 123))") | ||
(text "(:add_macros (macro foo 123))") | ||
(text "(:add_macros (macro foo () ))") | ||
(signals "invalid argument"))) | ||
|
||
(ion_1_1 "add_macros does not have any side-effects on the symbol table" | ||
(text "(:set_symbols a b c)") | ||
(then "[PRECONDITION] symbols are set as expected" | ||
(then (toplevel '#$1' '#$2' '#$3') (produces a b c)) | ||
(then (toplevel '#$4') (signals "invalid SID"))) | ||
(each (text "(:add_macros)") | ||
(text "(:add_macros (macro a () 123))") | ||
(text "(:add_macros (macro a () 123) (macro b () 456))") | ||
(then "no symbols are removed" | ||
(toplevel '#$1' '#$2' '#$3') (produces a b c)) | ||
(then "no symbols are added" | ||
(toplevel '#$4') (signals "invalid SID")))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,85 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test Cases: | ||
// add_symbols can be invoked using any type of macro reference. | ||
// the argument values may be zero or more non-null text values | ||
// add_symbols does not have any side-effects on the macro table | ||
// add_symbols should append its arguments to the symbol table of the default module | ||
// annotations on any argument value should signal an error (because it's not allowed in the symbol table rather than because of any specific validation by the add_symbols macro) | ||
(ion_1_1 "add_symbols can be invoked" | ||
(each "in text with an unqualified macro name" | ||
(text ''' (:add_symbols "") ''') | ||
"in text with an unqualified macro address" | ||
(text ''' (:12 "") ''') | ||
"in text with a qualified macro name" | ||
(text ''' (:$ion::add_symbols "") ''') | ||
"in text with a qualified macro address 12" | ||
(text ''' (:$ion::12 "") ''') | ||
"in binary with a system macro address 12" | ||
(binary "EF 0C 01 90") | ||
"in binary with a user macro address" | ||
(binary "0C 01 90") | ||
(then "and produces only system values" | ||
(produces)) | ||
(then "and affects the symbol table" | ||
(toplevel '#$1' '#$65' '#$66') | ||
(produces '$ion' 'make_field' '')))) | ||
|
||
(ion_1_1 "add_symbols can accept" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly, I think |
||
(then "an empty expression group" | ||
(text "(:add_symbols)") | ||
(then "with no error and producing no user values" | ||
(produces)) | ||
(then "and does not remove any symbols" | ||
(toplevel '#$1' '#$65') | ||
(produces '$ion' 'make_field')) | ||
(then "and does not add any symbols" | ||
(toplevel '#$66') | ||
(signals "invalid symbol id"))) | ||
(each "a single string" | ||
(text "(:add_symbols '''a''')") | ||
"a single symbol" | ||
(text "(:add_symbols 'a')") | ||
(then "with no error and producing no user values" | ||
(produces)) | ||
(then "and does not remove any symbols" | ||
(toplevel '#$1' '#$65') | ||
(produces '$ion' 'make_field')) | ||
(then "and appends the new symbol to the symbol table" | ||
(toplevel '#$66') | ||
(produces 'a'))) | ||
(each "multiple strings" | ||
(text ''' (:add_symbols "a" "b" "c") ''') | ||
"multiple symbols" | ||
(text ''' (:add_symbols 'a' 'b' 'c') ''') | ||
"a mix of strings and symbols" | ||
(text ''' (:add_symbols 'a' "b" 'c') ''') | ||
(then "with no error and producing no user values" | ||
(produces)) | ||
(then "and does not remove any symbols" | ||
(toplevel '#$1' '#$65') | ||
(produces '$ion' 'make_field')) | ||
(then "and appends the new symbols to the symbol table" | ||
(toplevel '#$66' '#$67' '#$68') | ||
(produces 'a' 'b' 'c')))) | ||
|
||
(ion_1_1 "add_symbols does not accept" | ||
(each "null" | ||
(text "(:add_symbols null)") | ||
"null.symbol" | ||
(text "(:add_symbols null.symbol)") | ||
"null.string" | ||
(text "(:add_symbols null.string)") | ||
"annotated arguments" // because of the symbol table syntax rather than any specific restriction of this macro | ||
(text "(:add_symbols a::b)") | ||
"symbols with unknown text and sid >0" | ||
(text "(:add_symbols $256)") | ||
(signals "invalid argument"))) | ||
|
||
(ion_1_1 "add_symbols does not have any side-effects on the macro table" | ||
(text "(:set_macros (macro x () X))") | ||
(then "[PRECONDITION] macros are set as expected" | ||
(text "(:x) (:0)") | ||
(produces X X)) | ||
(each (text "(:$ion::add_symbols)") | ||
(text "(:$ion::add_symbols 'a')") | ||
(text "(:$ion::add_symbols 'a' 'b')") | ||
// TODO: If it's not too difficult, assert that no macros are added | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you just assert that attempting to invoke There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe, but I'm going to wait for the dust to settle on the Modules part of the spec first. |
||
(then "no macros are removed" | ||
(text "(:x) (:0)") | ||
(produces X X)))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,87 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test Cases: | ||
// set_macros can be invoked using any type of macro reference. | ||
// the argument values may be zero or more macro definitions | ||
// TODO: Could it also be a module or an export? | ||
// set_macros does not have any side-effects on the symbol table | ||
// set_macros replaces the current macro table with a new macro table that consists of the arguments of set_macros | ||
// annotations on any argument value should signal an error (because it's not allowed in the macro table rather than because of any specific validation by the set_macros macro) | ||
// TODO: set_macros can accept a module name (of a loaded module) as an argument? | ||
// TODO: set_macros can accept a module/macro export? | ||
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thoughts as on |
||
|
||
(ion_1_1 "set_macros can be invoked" | ||
(each "in text with an unqualified macro name" | ||
(text "(:set_macros) ") | ||
"in text with an unqualified macro address" | ||
(text "(:13)") | ||
"in text with a qualified macro name" | ||
(text "(:$ion::set_macros)") | ||
"in text with a qualified macro address 13" | ||
(text "(:$ion::13)") | ||
"in binary with a system macro address 13" | ||
(binary "EF 0D 00") | ||
"in binary with a user macro address" | ||
(binary "0D 00") | ||
(produces))) | ||
|
||
(ion_1_1 "set_macros can be invoked with a single macro" | ||
(text "(:set_macros (macro x () X))") | ||
(each "which can be invoked by name" | ||
(text "(:x)") | ||
"which can be invoked by address" | ||
(text "(:0)") | ||
(produces X)) | ||
(then "then set_macros can accept" | ||
(then "an empty expression group" | ||
(text "(:$ion::set_macros (::))") | ||
(then "with no error and producing no user values" | ||
(produces)) | ||
(then "and it removes existing macros" | ||
(text "(:x)") | ||
(signals "unknown macro"))) | ||
(then "a single macro" | ||
(text "(:$ion::set_macros (macro foo () 123))") | ||
(then "with no error and producing no user values" | ||
(produces)) | ||
(then "and it removes existing macros" | ||
(text "(:x)") | ||
(signals "unknown macro")) | ||
(each "and it sets macro table with the new macro" | ||
(text "(:foo)") | ||
(text "(:0)") | ||
(produces 123))) | ||
(then "multiple macros" | ||
(text '''(:$ion::set_macros (macro foo () 123) | ||
(macro null () 456) | ||
(macro bar () 789))''') | ||
(then "with no error and producing no user values" | ||
(produces)) | ||
(then "and it removes existing macros" | ||
(text "(:x)") | ||
(signals "unknown macro")) | ||
(each "and it sets macro table with the new macros" | ||
(text "(:foo) (:1) (:bar)") | ||
(text "(:0) (:1) (:2)") | ||
(produces 123 456 789))))) | ||
|
||
(ion_1_1 "set_macros does not accept" | ||
(each "nulls" | ||
(text "(:set_macros null)") | ||
(text "(:set_macros null.symbol)") | ||
(text "(:set_macros null.sexp)") | ||
"invalid macro definitions" | ||
(text "(:set_macros a::(macro foo () 123))") | ||
(text "(:set_macros (macro $0 () 123))") | ||
(text "(:set_macros ( foo () 123))") | ||
(text "(:set_macros (macro () 123))") | ||
(text "(:set_macros (macro foo 123))") | ||
(text "(:set_macros (macro foo () ))") | ||
(signals "invalid argument"))) | ||
|
||
(ion_1_1 "set_macros does not have any side-effects on the symbol table" | ||
(text "(:set_symbols a b c)") | ||
(then "[PRECONDITION] symbols are set as expected" | ||
(then (toplevel '#$1' '#$2' '#$3') (produces a b c)) | ||
(then (toplevel '#$4') (signals "invalid SID"))) | ||
(each (text "(:set_macros)") | ||
(text "(:set_macros (macro a () 123))") | ||
(text "(:set_macros (macro a () 123) (macro b () 456))") | ||
(then "no symbols are removed" | ||
(toplevel '#$1' '#$2' '#$3') (produces a b c)) | ||
(then "no symbols are added" | ||
(toplevel '#$4') (signals "invalid SID")))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,82 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
// Test Cases: | ||
// set_symbols can be invoked using any type of macro reference. | ||
// the argument values may be zero or more non-null text values | ||
// set_symbols does not have any side-effects on the macro table | ||
// set_symbols replaces the current symbol table with a new symbol table that consists of the arguments of set_symbols | ||
// annotations on any argument value should signal an error (because it's not allowed in the symbol table rather than because of any specific validation by the set_symbols macro) | ||
(ion_1_1 "set_symbols can be invoked" | ||
(each "in text with an unqualified macro name" | ||
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment RE: |
||
(text ''' (:set_symbols "") ''') | ||
"in text with an unqualified macro address" | ||
(text ''' (:11 "") ''') | ||
"in text with a qualified macro name" | ||
(text ''' (:$ion::set_symbols "") ''') | ||
"in text with a qualified macro address 11" | ||
(text ''' (:$ion::11 "") ''') | ||
"in binary with a system macro address 11" | ||
(binary "EF 0B 01 90") | ||
"in binary with a user macro address" | ||
(binary "0B 01 90") | ||
(then "and produces only system values" | ||
(produces)) | ||
(then "and affects the symbol table" | ||
(toplevel '#$1') | ||
(produces '')))) | ||
|
||
(ion_1_1 "set_symbols can accept" | ||
(then "an empty expression group" | ||
(text "(:set_symbols (::))") | ||
(then "with no error and producing no user values" | ||
(produces)) | ||
(then "and clears the symbol table" | ||
(toplevel '#$1') | ||
(signals "invalid symbol id"))) | ||
(each "a single string" | ||
(text "(:set_symbols '''a''')") | ||
"a single symbol" | ||
(text "(:set_symbols 'a')") | ||
(then "with no error and producing no user values" | ||
(produces)) | ||
(then "and sets the symbol table" | ||
(toplevel '#$1') | ||
(produces 'a')) | ||
(then "and clears any existing symbols" | ||
(toplevel '#$2') | ||
(signals "invalid symbol id"))) | ||
(each "multiple strings" | ||
(text ''' (:set_symbols "a" "b" "c") ''') | ||
"multiple symbols" | ||
(text ''' (:set_symbols 'a' 'b' 'c') ''') | ||
"a mix of strings and symbols" | ||
(text ''' (:set_symbols 'a' "b" 'c') ''') | ||
(then "with no error and producing no user values" | ||
(produces)) | ||
(then "and sets the symbol table" | ||
(toplevel '#$1' '#$2' '#$3') | ||
(produces 'a' 'b' 'c')) | ||
(then "and clears any existing symbols" | ||
(toplevel '#$4') | ||
(signals "invalid symbol id")))) | ||
|
||
(ion_1_1 "set_symbols does not accept" | ||
(each "null" | ||
(text "(:set_symbols null)") | ||
"null.symbol" | ||
(text "(:set_symbols null.symbol)") | ||
"null.string" | ||
(text "(:set_symbols null.string)") | ||
"annotated arguments" // because of the symbol table syntax rather than any specific restriction of this macro | ||
(text "(:set_symbols a::b)") | ||
"symbols with unknown text and sid >0" | ||
(text "(:set_symbols $256)") | ||
(signals "invalid argument"))) | ||
|
||
(ion_1_1 "set_symbols does not have any side-effects on the macro table" | ||
(text "(:set_macros (macro x () X))") | ||
(then "[PRECONDITION] macros are set as expected" | ||
(text "(:x) (:0)") | ||
(produces X X)) | ||
(each (text "(:$ion::set_symbols)") | ||
(text "(:$ion::set_symbols 'a')") | ||
(text "(:$ion::set_symbols 'a' 'b')") | ||
// TODO: If it's not too difficult, assert that no macros are added | ||
(then "no macros are removed" | ||
(text "(:x) (:0)") | ||
(produces X X)))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think so. The options would be:
(macro name () body)
to define a macro in-situ.macro_ref
(qualified or unqualified) to add an already-defined macromodule_name::*
to add all ofmodule_name
's exported macrosNote that
foo
would be considered an unqualified macro name rather than a module, which is whyfoo::*
exists.