Make it easier to write deterministic tests.

Continues Akim's work from his 2009-06-10 commits.
* src/reader.c (check_and_convert_grammar): Don't add any
symbols after the first symbols_do invocation.
* src/symtab.c (symbols_sorted): New static global.
(user_token_number_redeclaration): Update comments.
(symbol_from_uniqstr): If a new symbol is being created, assert
that symbols_sorted hasn't been allocated yet.
(symbols_free): Free symbols_sorted.
(symbols_cmp, symbols_cmp_qsort): New functions.
(symbols_do): Sort symbol_table into symbols_sorted on first
invocation.
* tests/input.at (Numbered tokens): Recombine tests now that the
output should be deterministic across multiple numbers.
This commit is contained in:
Joel E. Denny
2009-08-08 20:19:01 -04:00
parent 28169bab1f
commit 83b60c97ee
4 changed files with 72 additions and 33 deletions

View File

@@ -675,33 +675,23 @@ AT_CLEANUP
AT_SETUP([Numbered tokens])
AT_DATA_GRAMMAR([1.y],
[[%token DECIMAL 11259375
HEXADECIMAL 0xabcdef
AT_DATA_GRAMMAR([redecl.y],
[[%token DECIMAL_1 11259375
HEXADECIMAL_1 0xabcdef
HEXADECIMAL_2 0xFEDCBA
DECIMAL_2 16702650
%%
start: DECIMAL;
start: DECIMAL_1 HEXADECIMAL_2;
]])
AT_BISON_CHECK([1.y], [1], [],
[[1.y:10.10-20: user token number 11259375 redeclaration for HEXADECIMAL
1.y:9.8-14: previous declaration for DECIMAL
AT_BISON_CHECK([redecl.y], [1], [],
[[redecl.y:10.10-22: user token number 11259375 redeclaration for HEXADECIMAL_1
redecl.y:9.8-16: previous declaration for DECIMAL_1
redecl.y:12.10-18: user token number 16702650 redeclaration for DECIMAL_2
redecl.y:11.10-22: previous declaration for HEXADECIMAL_2
]])
AT_DATA_GRAMMAR([2.y],
[[%token HEXADECIMAL 0xabcdef
DECIMAL 11259375
%%
start: HEXADECIMAL;
]])
AT_BISON_CHECK([2.y], [1], [],
[[2.y:10.10-16: user token number 11259375 redeclaration for DECIMAL
2.y:9.8-18: previous declaration for HEXADECIMAL
]])
AT_DATA_GRAMMAR([3.y],
AT_DATA_GRAMMAR([too-large.y],
[[%token TOO_LARGE_DEC 999999999999999999999
TOO_LARGE_HEX 0xFFFFFFFFFFFFFFFFFFF
%%
@@ -709,9 +699,9 @@ start: TOO_LARGE_DEC TOO_LARGE_HEX
%%
]])
AT_BISON_CHECK([3.y], [1], [],
[[3.y:9.22-42: integer out of range: `999999999999999999999'
3.y:10.24-44: integer out of range: `0xFFFFFFFFFFFFFFFFFFF'
AT_BISON_CHECK([too-large.y], [1], [],
[[too-large.y:9.22-42: integer out of range: `999999999999999999999'
too-large.y:10.24-44: integer out of range: `0xFFFFFFFFFFFFFFFFFFF'
]])
AT_CLEANUP