Add test cases for design alias names #30

This commit is contained in:
Thomas Jensen 2021-03-21 12:35:58 +01:00
parent 44f4c8adaa
commit 5650f251fd
No known key found for this signature in database
GPG Key ID: A4ACEE270D0FB7DB
11 changed files with 344 additions and 23 deletions

View File

@ -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)

View File

@ -5,6 +5,7 @@
:EXPECTED
Complete Design Information for "<Command Line Definition>":
------------------------------------------------------------
Alias Names: none
Author: (unknown author)
Original Designer: (unknown artist)
Creation Date: now

View File

@ -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

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"