aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/testsuite.at
blob: dd37053e8e9fba68c7ba6619d24a85861c1a19e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
AT_INIT
AT_COLOR_TESTS

# NOTE: There is currently no way to influence the return
# code of SciTECO, except to provoke an error.
# Since errors cannot be yielded explicitly, we use the
# idiom "(0/0)" to enforce a "Division by zero" error
# whenever we want to fail.
#
# NOTE: Square brackets are significant for M4 but
# often required in TECO code as well.
# We therefore use double brackets [[ ... ]]
# (translated to [ ... ]) in simple cases where balanced
# brackets are required in TECO code as well and
# quadrigraphs (@<:@ and @:>@) in all other cases.

AT_BANNER([Features])

AT_SETUP([Missing left operand])
AT_CHECK([$SCITECO -e '+23='], 1, ignore, ignore)
AT_CLEANUP

AT_SETUP([Closing loops at the correct macro level])
AT_CHECK([$SCITECO -e '@^Ua{>} <Ma'], 1, ignore, ignore)
AT_CLEANUP

AT_SETUP([String arguments])
AT_CHECK([$SCITECO -e $'Ifoo^Q\e(0/0)\e'], 0, ignore, ignore)
AT_CHECK([$SCITECO -e '@I"foo^Q"(0/0)"'], 0, ignore, ignore)
AT_CHECK([$SCITECO -e '@I{foo{bar}foo^Q{(0/0)}'], 0, ignore, ignore)
AT_CHECK([$SCITECO -e '@Ia^EQa(0/0)a'], 0, ignore, ignore)
# TODO: String building characters
AT_CLEANUP

AT_SETUP([Q-Register definitions])
AT_CHECK([$SCITECO -e '0Ua'], 0, ignore, ignore)
AT_CHECK([$SCITECO -e '0U.a'], 0, ignore, ignore)
AT_CHECK([$SCITECO -e '0U#ab'], 0, ignore, ignore)
AT_CHECK([$SCITECO -e '0U.#ab'], 0, ignore, ignore)
AT_CHECK([$SCITECO -e '0U[[AB]]'], 0, ignore, ignore)
AT_CHECK([$SCITECO -e '0U.[[AB]]'], 0, ignore, ignore)
AT_CHECK([$SCITECO -e '0U[[AB^Q@:>@(0/0)]]'], 0, ignore, ignore)
# TODO: String building in Q-Register definitions
AT_CLEANUP

AT_SETUP([8-bit cleanlyness])
AT_CHECK([$SCITECO -e "0:@EUa/f^@^@/ :Qa-4\"N(0/0)' Ga Z= Z-4\"N(0/0)'"], 0, ignore, ignore)
AT_CLEANUP

AT_SETUP([Automatic EOL normalization])
AT_CHECK([$SCITECO -e "@EB'${srcdir}/autoeol-input.txt' EL-2\"N(0/0)' 2LR 13@I'' 0EL @EW'autoeol-sciteco.txt'"],
         0, ignore, ignore)
AT_CHECK([cmp autoeol-sciteco.txt ${srcdir}/autoeol-output.txt], 0, ignore, ignore)
AT_CLEANUP

AT_SETUP([Memory limiting])
AT_CHECK([$SCITECO -e "50*1000*1000,2EJ <@<:@a>"], 1, ignore, ignore)
AT_CLEANUP

AT_SETUP([Execute external command])
# TODO: It would be a better test to generate a random number of bytes.
# Unfortunately, neither $RANDOM, shuf nor jot are portable.
# So we have to wait until SciTECO supports a random number generator.
AT_CHECK([$SCITECO -e "@EC'dd if=/dev/zero bs=512 count=1' Z= Z-512\"N(0/0)'"], 0, ignore, ignore)
AT_CHECK([$SCITECO -e "0,128ED @EC'dd if=/dev/zero bs=512 count=1' Z= Z-512\"N(0/0)'"], 0, ignore, ignore)
AT_CLEANUP

AT_BANNER([Regression Tests])

AT_SETUP([Glob patterns with character classes])
# Also checks closing brackets as part of the character set.
AT_CHECK([$SCITECO -e ":@EN/*.[[@:>@ch]]/foo.h/\"F(0/0)'"], 0, ignore, ignore)
AT_CLEANUP

AT_SETUP([Glob patterns with unclosed trailing brackets])
AT_CHECK([$SCITECO -e ":@EN/*.@<:@h/foo.@<:@h/\"F(0/0)'"], 0, ignore, ignore)
AT_CLEANUP

AT_SETUP([Searching with large counts])
# Even though the search will be unsuccessful, it will not be considered
# a proper error, so the process return code is still 0.
AT_CHECK([$SCITECO -e "2147483647@S/foo/"], 0, ignore, ignore)
# Will always break the memory limit which is considered an error.
AT_CHECK([$SCITECO -e "-2147483648@S/foo/"], 1, ignore, ignore)
AT_CLEANUP

AT_SETUP([Memory limiting during spawning])
# This might result in an OOM if memory limiting is not working
AT_CHECK([$SCITECO -e "50*1000*1000,2EJ 0,128ED @EC'dd if=/dev/zero'"], 1, ignore, ignore)
AT_CLEANUP

AT_SETUP([Q-Register stack cleanup])
AT_CHECK([$SCITECO -e '@<:@a'], 0, ignore, ignore)
AT_CLEANUP

AT_SETUP([Uninitialized "_"-register])
AT_CHECK([$SCITECO -e ":@S//\"S(0/0)'"], 0, ignore, ignore)
AT_CHECK([$SCITECO -e ":@EN///\"S(0/0)'"], 0, ignore, ignore)
AT_CLEANUP

AT_SETUP([Uninitialized Q-Register in string building])
AT_CHECK([$SCITECO -e '@I/^E@a/'], 0, ignore, ignore)
AT_CHECK([$SCITECO -e '@I/^ENa/'], 0, ignore, ignore)
AT_CLEANUP

AT_SETUP([Empty help topic])
AT_CHECK([$SCITECO -e '@?//'], 1, ignore, ignore)
AT_CLEANUP

AT_SETUP([Empty lexer name])
AT_CHECK([$SCITECO -e '@ES/SETILEXER//'], 1, ignore, ignore)
AT_CLEANUP

AT_BANNER([Known Bugs])

# NOTE: This bug depends on specific build options of Glib's
# PCRE which is not predictable.
#AT_SETUP([Pattern matching overflow])
## Should no longer dump core.
## It could fail because the memory limit is exceeed,
## but not in this case since the match string isn't too large.
#AT_CHECK([$SCITECO -e '100000<@I"X">J @S"^EM^X"'], 0, ignore, ignore)
#AT_XFAIL_IF(true)
#AT_CLEANUP

AT_SETUP([Recursion overflow])
# On Mac OS we cannot always reliably provoke a stack overflow.
AT_SKIP_IF([case $host in *-*-darwin*) true;; *) false;; esac])
# Should no longer dump core.
# It could fail because the memory limit is exceeed,
# but not in this case since we limit the recursion.
AT_CHECK([$SCITECO -e "@^Um{U.a Q.a-100000\"<%.aMm'} 0Mm"], 0, ignore, ignore)
AT_XFAIL_IF(true)
AT_CLEANUP