I just introduced a bug in the BBC BASIC implementation meaning that
'load-file' was broken on files over 255 bytes long, and it was only
caught by the optional test of 'time-ms' in step A. This change brings
forward the relevant part of that test so the failure can be detected
earlier and more obviously, at the same time as the other tests of
'load-file'.
When testing `foo.mal`, it makes sense to report parsing errors in
`foo.mal`.
Move tests of `->` and `->>` from `tests/step8_macros.mal` to
`tests/lib/theading.mal`.
Add `lib/trivial.mal`.
equality.mal:
- fix typos
- let and2 and or2 always return booleans
- when looping in sequences, compare lengths only once
- empty? instead of an equality test
- when looping on a keys, do not check if a contains the current key
- change the `cond` logic: when a is a sequence and b a map, return
false instead of delegating to scalar-equal?.
- add tests
memoize.mal:
- make explicit that the function name must be kept
- fix typo in tests
protocols.mal:
- document
- add a function mapping an object to its type
- add default types for remaining built-in MAL values
- let defprotocol return the new protocol instead of last method
- set the right profile for abstract methods, improving error messages
- replace incomplete example with lots of tests
pprint:
- escape parenthesis in expected test results
[kanaka]
- explain in lib/README.md how to run tests/lib/*.
- rename folds to reducers and composition to threading
- move fib and sumdown from lib/ to tests/
Partial translation of examples from lib/ to new tests.
Correct test of memoize.
`reduce`, `foldr`, `every?`, `some` and `and` were previously not
tested in tests/step*.mal. Tests them in `tests/lib/` instead.
In the BBC BASIC implementation, the empty list, vector, and hash-mapp
are distinguished values and detected by their address. Adding metadata
to them makes a copy, and then they don't work properly any more.
Self-hosting currently requires that these functions be defined so
that the mal implementation can pass them through. This test
minimally ensures that.
tests: check that `inc` is present in stepA.
nasm: split lines in mal_startup_string for readability.
objpascal: remove obsolete .orig file
swift: remove an unneeded line in template
swift4: remove duplicate definition of `or` macro
In the BBC BASIC implementation, lists and vectors are essentially the
same, and are only distinguished by a flag on the head node. This makes
it cheap to convert between lists and vectors, but it does require a
little care to ensure that a vector doesn't escape where it shouldn't.
The new test checks for a case where I'd got this wrong:
(rest (cons 10 [11 12]))
Here the 'cons' returns a list, but the tail of the list is just the
original vector (complete with vector flag), so a naïve implementation
of 'rest' can end up returning that vector instead of an equivalent
list. The test proves that it doesn't.
In these implementations there is no empty list check before
macroexpansion and so empty lists from step8 onwards produce a crash
or other misbehavior.
Also, add a test to step8 to test empty list again (first time it's
tested is in step2).
Strings are deferrable until step 6, so tests of string functionality at
step 4 should be marked as deferrable. A couple of tests just use
strings as convenient constants to return or print. In those cases,
replace the strings with integers rather than deferring the whole test.
The test makes more sense in step6.
Thanks to kanaka for the read-string suggestion.
Introduction of tail call optimization in step5 was making let* affect
the parent environment. This was partially fixed in later steps.
Introduction of macros in step8 was breaking the evaluation of an
empty list. This was fixed by step 9 but never backported.
- Update to support the new behavior of varargs and table.pack/unpack
in lua 5.2
- Bump up the stack overflow test since lua 5.2 seems to support much
larger stacks before overflow.
- Fix a latent issue in if forms where false in the 4th position would
result in nil returned. Add a new test to catch this in the future.
Add a step1 test to make sure that implementations are properly
throwing an error on unclosed strings.
Fix 47 implementations and update the guide to note the correct
behavior.
Fixes made to: ada, c, chuck, clojure, coffee, common-lisp, cpp,
crystal, d, dart, elm, erlang, es6, factor, fsharp, gnu-smalltalk,
groovy, guile, haxe, hy, js, livescript, matlab, miniMAL, nasm, nim,
objc, objpascal, ocaml, perl, perl6, php, plsql, ps, python, r,
rpython, ruby, scheme, swift3, tcl, ts, vb, vimscript, wasm, yorick.
Catchless try* test is an optional test. Not all implementations
support catchless try* but a number were fixed so they at least don't
crash on catchless try*.
The run-fn-for function was originally name run-fn and was hard-coded
to run for 3 seconds. I forgot to replace the 3 with the max-secs
variable. However, given that some implementations have less than
1 iteration per second, I'm just going to drop that division and
report the iterations per max-seconds so that for the slowest
implementations we have some relative comparison instead of all of
them just reporting 0.
Thanks to Tim Morgan for discovering this bug:
699f0ad23a
In Java the time-ms value was negative. This actually still works fine
because arithmetic comparison is still correct. So allow signed
time-ms results.
Concatenating multiple empty lists resulted in a return
which should be empty but was not checked.
(concat (list) (list))
-> ()
Test added to step 7 to catch, since this appeared in
self-hosting step 8 in the -> macro expansion.
Several implementations fail when unescaping "\\n" in their reader
module because string-wide replacements of the two chars '\' and 'n' by
a newline char will replace the last two chars.
- Strip linefeeds in run_argv_test.sh so that step6 arg test passes
for basic.
- Add gensym and convert or macro.
- Add gitignore entries for transpiled basic sources.
- Add conj/seq stubs so that step4 self-host loads (if non-step4
functions are commented out in core.mal)
- Bump up Z% value space by 256 spaces (1K)
- Remove old qb2cbm.sh
- Move apply logic in swap! to APPLY function in types and use that
for macroexpand
- Abort def! if error before updating the environment
- let* wasn't properly saving A2% for the final eval. Also, the
environment release check should be against the top-level EVAL env,
not the root repl env.
- (concat (list) ...) was broken so fix it to ignore empty lists that
aren't in the trailing position.
- nil, false and true in the reader were always being returned as
references (with an ref cnt) but we have the assumption that
references (14) are not ref cnt'd and are always part of a compound
type so fix the reader to just return the interned addresses.
Also:
- Add some step1 and step3 tests that were discovered during Basic
development.
- Move PR_MEMORY* to debug.in.bas
- Simplify Makefile deps
- Fix freeing in steps4-7 when error at deeper level
i.e. (prn (abc))
- add SLICE function to support concat implementation.
Add new mini test harness run_argv_test.sh to run the Mal interpreter
with different command-line arguments and test the stdout of that
process.
The main Makefile will automatically run the new harness whenever step 6
is tested (either directly or during REGRESS=1 of a more advanced step).
- tests/*: marked with deferable and optional runtest flags. Some
moving around of tests within different sections to more closely
align with the guide.
- runtest.py has --deferable/--no-deferable and
--optional/--no-optional to control whether tests marked as
deferable and optional are tested.
- Makefile: DEFERABLE and OPTIONAL top level flags to be passed to
runtest when running tests.
- Also, fix problems in java quoting revealed by step7 test changes.
- Remove most of the step5 excludes in the Makefile except for ones
which don't have TCO capability at all (or the implementation is too
slow): bash, make, mal, matlab.
- Make perf_EXCLUDES consistent with other excludes.
- Add a print-FOO target which prints the resolved value of Makefile
variable FOO. For example, `make print-IMPLS` to print the list of
implementations.
1. `gensym` isn't yet available in step8
2. `and` tests are very slow in some implementations
3. ->> macro is more complex
4. moved core.mal to the end so it won't override the builtin `or` macro