From 5650f251fd70af4a4156c2d946b2f0ac09bec507 Mon Sep 17 00:00:00 2001 From: Thomas Jensen Date: Sun, 21 Mar 2021 12:35:58 +0100 Subject: [PATCH] Add test cases for design alias names #30 --- test/083_list_design_info.txt | 1 + ...ist_design_info_for_cmdline_definition.txt | 1 + test/135_design_alias_by_design.cfg | 21 ++++++ test/135_design_alias_by_design.txt | 27 +++++++ test/136_design_alias_by_alias.cfg | 75 +++++++++++++++++++ test/136_design_alias_by_alias.txt | 29 +++++++ test/137_design_alias_no_accumulation.cfg | 71 ++++++++++++++++++ test/137_design_alias_no_accumulation.txt | 27 +++++++ test/138_design_alias_duplicate_name.cfg | 68 +++++++++++++++++ test/138_design_alias_duplicate_name.txt | 24 ++++++ test/test-config-unused.cfg | 23 ------ 11 files changed, 344 insertions(+), 23 deletions(-) create mode 100644 test/135_design_alias_by_design.cfg create mode 100644 test/135_design_alias_by_design.txt create mode 100644 test/136_design_alias_by_alias.cfg create mode 100644 test/136_design_alias_by_alias.txt create mode 100644 test/137_design_alias_no_accumulation.cfg create mode 100644 test/137_design_alias_no_accumulation.txt create mode 100644 test/138_design_alias_duplicate_name.cfg create mode 100644 test/138_design_alias_duplicate_name.txt diff --git a/test/083_list_design_info.txt b/test/083_list_design_info.txt index 464a039..f7b49ae 100644 --- a/test/083_list_design_info.txt +++ b/test/083_list_design_info.txt @@ -5,6 +5,7 @@ :EXPECTED Complete Design Information for "c": ------------------------------------ +Alias Names: none Author: Thomas Jensen Original Designer: (public domain) Creation Date: March 18, 1999 (Thursday, 15:25h) diff --git a/test/084_list_design_info_for_cmdline_definition.txt b/test/084_list_design_info_for_cmdline_definition.txt index e9700f6..b375b1b 100644 --- a/test/084_list_design_info_for_cmdline_definition.txt +++ b/test/084_list_design_info_for_cmdline_definition.txt @@ -5,6 +5,7 @@ :EXPECTED Complete Design Information for "": ------------------------------------------------------------ +Alias Names: none Author: (unknown author) Original Designer: (unknown artist) Creation Date: now diff --git a/test/135_design_alias_by_design.cfg b/test/135_design_alias_by_design.cfg new file mode 100644 index 0000000..cd620bd --- /dev/null +++ b/test/135_design_alias_by_design.cfg @@ -0,0 +1,21 @@ + +BOX design, alias1, alias2 + +sample + X your text X +ends + +shapes { + w ("X") + e ("X") +} + +elastic ( + e, w +) + +padding { + horizontal 1 +} + +END design diff --git a/test/135_design_alias_by_design.txt b/test/135_design_alias_by_design.txt new file mode 100644 index 0000000..fb61640 --- /dev/null +++ b/test/135_design_alias_by_design.txt @@ -0,0 +1,27 @@ +:DESC +Test that the alias names of a design are properly listed in the design information sheet. + +:ARGS +-f 135_design_alias_by_design.cfg -l -d design +:INPUT +:OUTPUT-FILTER +:EXPECTED +Complete Design Information for "design": +----------------------------------------- +Alias Names: alias1, alias2 +Author: (unknown author) +Original Designer: (unknown artist) +Creation Date: (unknown) +Current Revision: (unknown) +Configuration File: 135_design_alias_by_design.cfg +Indentation Mode: box (indent box) +Replacement Rules: none +Reversion Rules: none +Minimum Box Dimensions: 3 x 3 (width x height) +Default Padding: left 1, right 1 +Default Killblank: no +Tags: (none) +Elastic Shapes: N, E, S, W +Defined Shapes: E: "X" + W: "X" +:EOF diff --git a/test/136_design_alias_by_alias.cfg b/test/136_design_alias_by_alias.cfg new file mode 100644 index 0000000..5ac2491 --- /dev/null +++ b/test/136_design_alias_by_alias.cfg @@ -0,0 +1,75 @@ + +BOX design1 + +sample + X1 your text X1 +ends + +shapes { + w ("X1") + e ("X1") +} + +elastic ( + e, w +) + +padding { + horizontal 1 +} + +END design1 + +# ------------------------------------------- + +BOX design2, alias2 + +sample + X2 your text X2 +ends + +shapes { + w ("X2") + e ("X2") +} + +elastic ( + e, w +) + +padding { + horizontal 1 +} + +END design2 + +# ------------------------------------------- + +BOX design3, + alias3a, # we refer to this design by this alias + alias3b + +# following sample block is empty +sample test4 +ends + +shapes { + e ("1","2","3") + w ("1","2","3","4","5") + + s ("#") n ("#") nw ("#") se ("#") sw ("#") ne ("#") +} + +elastic (n,s,e, w) + +END design3 + +# ------------------------------------------- + +BOX design4 + +sample + X your text X +ends + +... and so on, this part is no longer parsed. diff --git a/test/136_design_alias_by_alias.txt b/test/136_design_alias_by_alias.txt new file mode 100644 index 0000000..b2ec1fd --- /dev/null +++ b/test/136_design_alias_by_alias.txt @@ -0,0 +1,29 @@ +:DESC +Test that a design can be selected by alias, even when it is not the first design in the file. This tests that +lexer speedmode does not skip over alias names. + +:ARGS +-f 136_design_alias_by_alias.cfg -p h3 -a vc -d alias3a +:INPUT +foo +bar +:OUTPUT-FILTER +:EXPECTED +########### +1 1 +2 2 +3 3 +4 1 +5 2 +1 3 +2 foo 1 +3 bar 2 +4 3 +5 1 +1 2 +2 3 +3 1 +4 2 +5 3 +########### +:EOF diff --git a/test/137_design_alias_no_accumulation.cfg b/test/137_design_alias_no_accumulation.cfg new file mode 100644 index 0000000..412d3c4 --- /dev/null +++ b/test/137_design_alias_no_accumulation.cfg @@ -0,0 +1,71 @@ + +# The next line contains a syntax error, but it is not noticed in this test case +# because we don't parse the interior of skipped box designs! +BOX design1, alias 1 + +sample + X1 your text X1 +ends + +shapes { + w ("X1") + e ("X1") +} + +elastic ( + e, w +) + +padding { + horizontal 1 +} + +END design1 + +# ------------------------------------------- + +BOX design2, alias2 + +sample + X2 your text X2 +ends + +shapes { + w ("X2") + e ("X2") +} + +elastic ( + e, w +) + +padding { + horizontal 1 +} + +END design2 + +# ------------------------------------------- + +BOX design3, + alias3a, + alias3b # we refer to this design by this alias + +sample + X3 your text X3 +ends + +shapes { + w ("X3") + e ("X3") +} + +elastic ( + e, w +) + +padding { + horizontal 1 +} + +END design3 diff --git a/test/137_design_alias_no_accumulation.txt b/test/137_design_alias_no_accumulation.txt new file mode 100644 index 0000000..c570fd7 --- /dev/null +++ b/test/137_design_alias_no_accumulation.txt @@ -0,0 +1,27 @@ +:DESC +Test that the list of aliases is properly reset when lexer is in speedmode. + +:ARGS +-f 137_design_alias_no_accumulation.cfg -d alias3b -l +:INPUT +:OUTPUT-FILTER +:EXPECTED +Complete Design Information for "design3": +------------------------------------------ +Alias Names: alias3a, alias3b +Author: (unknown author) +Original Designer: (unknown artist) +Creation Date: (unknown) +Current Revision: (unknown) +Configuration File: 137_design_alias_no_accumulation.cfg +Indentation Mode: box (indent box) +Replacement Rules: none +Reversion Rules: none +Minimum Box Dimensions: 5 x 3 (width x height) +Default Padding: left 1, right 1 +Default Killblank: no +Tags: (none) +Elastic Shapes: N, E, S, W +Defined Shapes: E: "X3" + W: "X3" +:EOF diff --git a/test/138_design_alias_duplicate_name.cfg b/test/138_design_alias_duplicate_name.cfg new file mode 100644 index 0000000..d897700 --- /dev/null +++ b/test/138_design_alias_duplicate_name.cfg @@ -0,0 +1,68 @@ + +BOX design1 + +sample + X1 your text X1 +ends + +shapes { + w ("X1") + e ("X1") +} + +elastic ( + e, w +) + +padding { + horizontal 1 +} + +END design1 + +# ------------------------------------------- + +BOX design2, alias2 + +sample + X2 your text X2 +ends + +shapes { + w ("X2") + e ("X2") +} + +elastic ( + e, w +) + +padding { + horizontal 1 +} + +END design2 + +# ------------------------------------------- + +# Next line uses the same alias as design2, which is wrong: +BOX design3, alias2 + +sample + X3 your text X3 +ends + +shapes { + w ("X3") + e ("X3") +} + +elastic ( + e, w +) + +padding { + horizontal 1 +} + +END design3 diff --git a/test/138_design_alias_duplicate_name.txt b/test/138_design_alias_duplicate_name.txt new file mode 100644 index 0000000..7dde973 --- /dev/null +++ b/test/138_design_alias_duplicate_name.txt @@ -0,0 +1,24 @@ +:DESC +Test that we get an error if an alias already exists. + +:ARGS +-f 138_design_alias_duplicate_name.cfg -l +:INPUT +:OUTPUT-FILTER +:EXPECTED +boxes: 138_design_alias_duplicate_name.cfg: line 49: alias already in use -- alias2 +boxes: 138_design_alias_duplicate_name.cfg: line 49: skipping to next design +2 Available Styles in "138_design_alias_duplicate_name.cfg": +------------------------------------------------------------ + +design1: + + X1 your text X1 + + +design2 alias alias2: + + X2 your text X2 + + +:EOF diff --git a/test/test-config-unused.cfg b/test/test-config-unused.cfg index 50252c1..c62ea37 100644 --- a/test/test-config-unused.cfg +++ b/test/test-config-unused.cfg @@ -2,29 +2,6 @@ # Currently unused. -BOX test4 - -author "Thomas Jensen" -designer "Thomas Jensen" - -sample test4 -ends - -shapes { - e ("1","2","3") - w ("1","2","3","4","5") - - s ("#") n ("#") nw ("#") se ("#") sw ("#") ne ("#") -} - -elastic (n,s,e, w) - -END test4 - - -# ============================================================================ - - BOX test5 author "Thomas Jensen"