aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
AgeCommit message (Collapse)AuthorFilesLines
2024-02-06fixed the power (^*) operator: did not handle corner cases and was inefficientRobin Haberkorn1-0/+9
* in fact, with a negative exponent the previous naive implementation would even hang indefinitely! * Now uses the squaring algorithm. This is slightly longer but significantly more efficient. * added test cases
2024-01-13fixed <EC$> assertions: specifying empty command strings was undefinedRobin Haberkorn1-0/+5
* passing an empty command string down to the shell would always do nothing, so it doesn't make sense to support that. * for the time being, we generate a proper error * in the future, it might make sense to define some special behavior like repeating the last command - but EC does not currently save the command line anywhere. * The generated documentation is currently ugly (FIXME). mandatory parameters are not properly detected by tedoc and we cannot keep apart Q-Registers from mandatory parameters either. Also, we should allow <param> markup in command summaries.
2023-07-06fixed ]$ and ]~ (pop from Q-Reg stack to special Q-Registers)Robin Haberkorn1-0/+6
* This was setting only the teco_doc but wasn't calling the necessary set_string() methods. * The idiom [$ FG...$ ]$ to change the working directory temporarily now works. * Similarily you can now write [~ ^U~...$ ]~ to change the clipboard temporarily. * Added test suite cases. The clipboard is not tested since it's not supported everywhere and would interfer with the host system. * Resolved lots of redundancies in qreg.c. The clipboard and workingdir Q-Regs have lots in common. This is now abstracted in the "external" Q-Reg base "class" (ie. via initializer TECO_INIT_QREG_EXTERNAL()). It uses vtable calls which is slightly more inefficient than per register implementations, but avoiding redundancies is probably more important.
2023-05-14FreeBSD: fixed test suiteRobin Haberkorn1-2/+3
* it appears to behave similar to Mac OS with regard to recursions
2022-12-10fixed pass-through loops: especially :> and :F<Robin Haberkorn1-0/+29
* fixes test cases like 3<%a:> * you can now use :F< in pass-through loops as well * F> outside of loops will now exit the current macro level. This is analogous to what TECO-11 did. In interactive mode, F> is currently also equivalent to $$ (terminates command line).
2022-12-01testsuite: added (known bug) testcases for dangling else- and end-if statementsRobin Haberkorn1-0/+6
* This is not easy to fix (show errors when encountering these constructs without preceding if <"> statements) and would require complicating the parser only to detect this. On the other hand, keeping things as they are does not really harm anybody.
2022-11-28fixed a number of crashes due to empty string arguments or uninitialized ↵Robin Haberkorn1-2/+16
registers * An empty but valid teco_string_t can contain NULL pointers. More precisely, a state's done_cb() can be invoked with such empty strings in case of empty string arguments. Also a registers get_string() can return the NULL pointer for existing registers with uninitialized string parts. * In all of these cases, the language should treat "uninitialized" strings exactly like empty strings. * Not doing so, resulted in a number of vulnerabilities. * EN$$ crashed if "_" was uninitialized * The ^E@q and ^ENq string building constructs would crash for existing but uninitialized registers q. * ?$ would crash * ESSETILEXER$$ would crash * This is now fixed. Test cases have been added. * I cannot guarantee that I have found all such cases. Generally, it might be wise to change our definitions and make sure that every teco_string_t must have an associated heap object to be valid. All functions returning pointer+length pairs should consequently also never return NULL pointers.
2022-11-20test suite: temporarily disabled the "Pattern matching overflow" test caseRobin Haberkorn1-7/+9
* This test case no longer fails on MacOS and MinGW builds probably because the settings of the underlying libpcre library changed. * Since these settings are not predictable, cannot be queried and may even change on some flavors of Linux, it has been completely disabled for the time being. * Should fix CI and nightly builds on MacOS and Win32
2021-12-19safer use of memcpy() and memchr(): we must not pass in NULL pointersRobin Haberkorn1-0/+4
* The C standard actually forbids this (undefined behaviour) even though it seems intuitive that something like `memcpy(foo, NULL, 0)` does no harm. * It turned out, there were actual real bugs related to this. If memchr() was called with a variable that can be NULL, the compiler could assume that the variable is actually always non-NULL (since glibc declares memchr() with nonnull), consequently eliminating checks for NULL afterwards. The same could theoretically happen with memcpy(). This manifested itself in the empty search crashing when building with -O3. Test case: sciteco -e '@S//' * Consequently, the nightly builds (at least for Ubuntu) also had this bug. * In some cases, the passed in pointers are passed down from the caller but should not be NULL, so I added runtime assertions to guard against it.
2021-10-24fixed testsuite on Mac OS: skip the recursion overflow test caseRobin Haberkorn1-2/+3
* Turns out we cannot assume that the test case never crashes on Mac OS, so we instead now skip the entire test case on Mac OS. It apparently crashes even on Mac OS when building with --enable-debug (-O0). * Should fix Continous Integration for Mac OS.
2021-10-11fixed crashes when the Q-Reg stack is non-empty at exitRobin Haberkorn1-0/+4
* Test case: sciteco -e '[a' [aEX$$ in interactive mode would also crash. * No longer use a destructor - it was executed after the Q-Reg view was destroyed. * Instead, we now explicitly call teco_qreg_stack_clear() in main(). * Added a regression test case.
2021-10-08Testsuite: standardized the use of square brackets in test case code and ↵Robin Haberkorn1-9/+11
test escaping of braces in Q-Register specifications
2021-10-08Fixed testsuite on Mac OS: `echo -n` is apparently not supported on whatever ↵Robin Haberkorn1-4/+7
$SHELL they execute the testsuite in * instead, we now use `dd`.
2021-06-08added test suite cases for memory limiting and command executionRobin Haberkorn1-1/+11
* Turned out to be useful in debugging the "Memory limiting during spawning" test case on Windows. * Use UNIX shell emulation (0,128ED) in all test cases. Should be necessary in order to run the testsuite on Windows, but it is currently broken anyway. * avoid <EG> when preprocessing files - use GNU Make's $(shell) instead * Fixes builds on MinGW where there are still problems with <EC> and <EG> at least in the virtual build environment. * Results in a another automake warning about non-POSIX Make constructs. This is not critical since we depend on GNU Make anyway.
2021-06-05testsuite: fixed the "Known Bugs" cases on Mac OSRobin Haberkorn2-2/+5
* there is no /bin/true * We cannot crash SciTECO using unlimited recursion, at least not before the memory limit is reached. Therefore, this test case is expected to succeed on Mac OS.
2021-06-04guard against too low arguments to <S> by checking whether the memory limit ↵Robin Haberkorn1-1/+1
would be exceeded * Checking whether the allocation succeeded may not prevent exceeding the memory limit excessively. * Even if the memory limit is not exceeded, the allocation can fail theoretically and the program would terminate abnormally. This however is true for all allocations in SciTECO (via glib). * teco_memory_check() therefore now supports checking whether an allocation would exceed the memory limit which will be useful before very large or variable allocations in addition to the regular checking in teco_machine_main_step(). * As a sideeffect, this fixes the "Searching with large counts" test case on Mac OS where too large allocations were not detected as expected (apparently Mac OS happily gives out ridiculously large chunks of memory). Now, all platforms are guaranteed to have the same behaviour.
2021-05-30THE GREAT CEEIFICATION EVENTRobin Haberkorn2-0/+63
This is a total conversion of SciTECO to plain C (GNU C11). The chance was taken to improve a lot of internal datastructures, fix fundamental bugs and lay the foundations of future features. The GTK user interface is now in an useable state! All changes have been squashed together. The language itself has almost not changed at all, except for: * Detection of string terminators (usually Escape) now takes the string building characters into account. A string is only terminated outside of string building characters. In other words, you can now for instance write I^EQ[Hello$world]$ This removes one of the last bits of shellisms which is out of place in SciTECO where no tokenization/lexing is performed. Consequently, the current termination character can also be escaped using ^Q/^R. This is used by auto completions to make sure that strings are inserted verbatim and without unwanted sideeffects. * All strings can now safely contain null-characters (see also: 8-bit cleanliness). The null-character itself (^@) is not (yet) a valid SciTECO command, though. An incomplete list of changes: * We got rid of the BSD headers for RB trees and lists/queues. The problem with them was that they used a form of metaprogramming only to gain a bit of type safety. It also resulted in less readble code. This was a C++ desease. The new code avoids metaprogramming only to gain type safety. The BSD tree.h has been replaced by rb3ptr by Jens Stimpfle (https://github.com/jstimpfle/rb3ptr). This implementation is also more memory efficient than BSD's. The BSD list.h and queue.h has been replaced with a custom src/list.h. * Fixed crashes, performance issues and compatibility issues with the Gtk 3 User Interface. It is now more or less ready for general use. The GDK lock is no longer used to avoid using deprecated functions. On the downside, the new implementation (driving the Gtk event loop stepwise) is even slower than the old one. A few glitches remain (see TODO), but it is hoped that they will be resolved by the Scintilla update which will be performed soon. * A lot of program units have been split up, so they are shorter and easier to maintain: core-commands.c, qreg-commands.c, goto-commands.c, file-utils.h. * Parser states are simply structs of callbacks now. They still use a kind of polymorphy using a preprocessor trick. TECO_DEFINE_STATE() takes an initializer list that will be merged with the default list of field initializers. To "subclass" states, you can simply define new macros that add initializers to existing macros. * Parsers no longer have a "transitions" table but the input_cb() may use switch-case statements. There are also teco_machine_main_transition_t now which can be used to implement simple transitions. Additionally, you can specify functions to execute during transitions. This largely avoids long switch-case-statements. * Parsers are embeddable/reusable now, at least in parse-only mode. This does not currently bring any advantages but may later be used to write a Scintilla lexer for TECO syntax highlighting. Once parsers are fully embeddable, it will also be possible to run TECO macros in a kind of coroutine which would allow them to process string arguments in real time. * undo.[ch] still uses metaprogramming extensively but via the C preprocessor of course. On the downside, most undo token generators must be initiated explicitly (theoretically we could have used embedded functions / trampolines to instantiate automatically but this has turned out to be dangereous). There is a TECO_DEFINE_UNDO_CALL() to generate closures for arbitrary functions now (ie. to call an arbitrary function at undo-time). This simplified a lot of code and is much shorter than manually pushing undo tokens in many cases. * Instead of the ridiculous C++ Curiously Recurring Template Pattern to achieve static polymorphy for user interface implementations, we now simply declare all functions to implement in interface.h and link in the implementations. This is possible since we no longer hace to define interface subclasses (all state is static variables in the interface's *.c files). * Headers are now significantly shorter than in C++ since we can often hide more of our "class" implementations. * Memory counting is based on dlmalloc for most platforms now. Unfortunately, there is no malloc implementation that provides an efficient constant-time memory counter that is guaranteed to decrease when freeing memory. But since we use a defined malloc implementation now, malloc_usable_size() can be used safely for tracking memory use. malloc() replacement is very tricky on Windows, so we use a poll thread on Windows. This can also be enabled on other supported platforms using --disable-malloc-replacement. All in all, I'm still not pleased with the state of memory limiting. It is a mess. * Error handling uses GError now. This has the advantage that the GError codes can be reused once we support error catching in the SciTECO language. * Added a few more test suite cases. * Haiku is no longer supported as builds are instable and I did not manage to debug them - quite possibly Haiku bugs were responsible. * Glib v2.44 or later are now required. The GTK UI requires Gtk+ v3.12 or later now. The GtkFlowBox fallback and sciteco-wrapper workaround are no longer required. * We now extensively use the GCC/Clang-specific g_auto feature (automatic deallocations when leaving the current code block). * Updated copyright to 2021. SciTECO has been in continuous development, even though there have been no commits since 2018. * Since these changes are so significant, the target release has been set to v2.0. It is planned that beginning with v3.0, the language will be kept stable.
2017-03-23fixed checks for missing left and right operands to binary operatorsRobin Haberkorn1-0/+4
* this resulted in assertions (crashes!) for harmless typos like "+23=" * a test case has been added
2017-03-03build system portability fixesRobin Haberkorn1-1/+1
* especially to improve building on FreeBSD 11 * We need GNU Make, yet alone because Scintilla/Scinterm needs it. We now document that dependency and added an Autoconf check from the autoconf-archive. We make sure that the build process is invoked with GNU make by generating only GNUmakefiles. The Makefile.am files have not been renamed, so this change can be rolled back easily. * Some GNU-Make-specific autoreconf warnings have still been resolved. But not all of them, as this would have been unelegant and we need GNU Make anyway. * Declare ACLOCAL_AMFLAGS to appease autoreconf * Added an explicit check for C++11 from the autoconf-archives. In general we should support building with every C++11 compiler that is sufficiently GNU-like. * Do not use `sed` for inplace editing, as different sed-implementations have mutually incompatible syntax for this. Instead of declaring and checking a dependency on GNU sed, we simply use SciTECO for the editing task. This improves code portability on BSDs. * Similarily, BSD/POSIX `cmp` is supported now. This fixes the test suite on BSD without declaring a dependency on the GNU coreutils. * Simplified sciteco-wrapper generation.
2016-11-01globbing supports character classes now and ^EN string building construct to ↵Robin Haberkorn1-1/+19
escape glob patterns * globbing is fnmatch(3) compatible, now on every supported platform. * which means that escaping of glob patterns is possible now. ^ENq has been introduced to ease this task. * This finally allows you to pass unmodified filenames to EB. Previously it was impossible to open file names containing glob wildcards. * this was achieved by moving from GPattern to GRegex as the underlying implementation. * The glob pattern is converted to a regular expression before being compiled to a GRegex. This turned out to be trickier than anticipated (~140 lines of code) and has a runtime penalty of course (complexity is O(2*n) over the pattern length). It is IMHO still better than the alternatives, like importing external code from libiberty, which is potentially non-cross-platform. * Using GRegex also opens the potential of supporting brace "expansions" later in the form of glob pattern constructs (they won't actually expand but match alternatives). * is_glob_pattern() has been simplified and moved to Globber::is_pattern(). It makes sense to reuse the Globber class namespace instead of using plain functions for functions working on glob patterns. * The documentation has a new subsection on glob patterns now. * Testsuite extended with glob pattern test cases
2016-08-19added test group for SciTECO's EOL normalisation featureRobin Haberkorn5-0/+21
2016-02-16finally added Autotest suiteRobin Haberkorn3-0/+51
* Autotest ships with Autoconf, so it's available already and relatively easy to integrate into an Autotools package. * This is attached to `make check` using some Automake magic. * The test suite will only call the built SciTECO for the time being. But using tests/Makefile.am, custom programs could be easily built. * Since it uses the target sciteco, it cannot work in cross-compile environments. * The test suite tests/testsuite.at should be used for regression tests at least: Whenever there is a bug, a test case should be added to testsuite.at. Later this might be split up into multiple includes for regressions other tests.