1
1
mirror of https://github.com/kanaka/mal.git synced 2024-10-26 14:22:25 +03:00
Commit Graph

34 Commits

Author SHA1 Message Date
Nicolas Boulenguez
77057e6920 tests: soft-test metadata for atoms 2019-07-18 00:00:29 +02:00
Nicolas Boulenguez
809d74cba7 Implement macros with maps instead of vectors.
Output of macros will probably be more readable.

Inline _macro_wrap and _unwrap for efficiency (there are less
primitive operations for maps than for vectors).

Basic check of `map?` and `macro?`. Swap them in order to simplify the
diff with cb9b0654.
2019-07-14 19:47:58 +02:00
Nicolas Boulenguez
28b63c0ca6 mal: implement macro without metadata
Support for metadata becomes optional.
Support for fn? becomes optional again, reverting 5e5d4892.
2019-07-09 14:16:27 +02:00
Nicolas Boulenguez
aac5cf7bf5 guile, scheme: fix fn? when metadata contains "ismacro"
Let `with-meta f m` create a function even if f is a macro, instead of
setting an "ismacro" metadata that is never used again (and breaks
self-hosting).

Also move the test for fn? from Optional to Deferrable, the function
is used for self-hosting.
2019-07-09 14:14:03 +02:00
Nicolas Boulenguez
26ced15b31 Remove gensym, inc and or from step files.
* Move `gensym` and `inc` from step files to `lib/trivial.mal`.
* Move `or` from step files to `lib/test_cascade.mal`.
  Shorten it because `(first ())` returns `nil`
* Update process and tests accordingly (not the figures yet).
2019-07-09 14:05:29 +02:00
Nicolas Boulenguez
83665b4fda lib/: add tests, fix detected problems, improve implementations
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/
2019-05-18 01:52:13 +02:00
Nicolas Boulenguez
a1805b96af Move tests of lib/ and new tests of core.mal to tests/lib/.
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.
2019-05-18 01:52:13 +02:00
Nicolas Boulenguez
bf6647fbb3 Fix style issues in lib/.
This diff is best viewed without space differences.
2019-05-18 01:52:13 +02:00
Nicolas Boulenguez
3e9b89d4b5 Prepare move of reusable code to lib/.
Changes creating huge diffs, like file splits, have been delayed for
readability .
Also fix description of `and`.
2019-05-18 01:52:13 +02:00
Joel Martin
976e03b912
Merge pull request #378 from asarhaddon/test-macro-not-changing-function
Test that defining a macro does not mutate an existing function.
2019-05-15 08:17:59 -07:00
Nicolas Boulenguez
c714889a98 Move test that macro do not mutate functions as optional in stepA 2019-05-15 06:19:02 +02:00
Joel Martin
bf5cba817e
Merge pull request #376 from bjh21/bjh21-withmeta-empty
step A: Test that metadata doesn't break empty collections.
2019-05-14 17:25:35 -07:00
Ben Harris
bfb315c852 step A: Test that metadata doesn't break empty collections.
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.
2019-05-14 23:28:13 +01:00
Ben Harris
3b1a665234 step A: Add a mandatory test that 'string?' etc are defined.
Self-hosting currently requires that these functions be defined so
that the mal implementation can pass them through.  This test
minimally ensures that.
2019-05-14 22:22:39 +01:00
Nicolas Boulenguez
14ab099cea gensym: hide the counter in an environment, define inc in stepA.
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
2019-05-11 16:37:26 +02:00
Joel Martin
bbd62dc97c tests/stepA: allow time-ms result to be signed.
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.
2018-07-12 14:24:14 -05:00
Joel Martin
393d1140a3 tests: move number?, fn? and macro? to optional 2017-11-01 21:56:29 -05:00
Vasilij Schneidermann
2ff47a342f Fix typo 2017-10-23 17:15:42 +02:00
Dov Murik
69edbad782 tests: Use a real user-defined function when testing fn? and macro? 2017-10-14 12:20:53 +00:00
Dov Murik
59436f1a12 Add number?, fn?, macro? in stepA - tests and process guide
Ref #298
2017-10-09 20:23:39 +00:00
Joel Martin
a1eb30fcc9 Use more common spelling of deferrable.
Deferable is apprently a less common but correct spelling.
2016-05-10 10:26:39 -05:00
Joel Martin
46e2568944 Makefile/runtest/tests: deferable/optional options
- 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.
2016-05-09 21:14:15 -05:00
Dov Murik
44c9a7d8be mal: Add time-ms to core; add tests for time-ms 2016-03-09 13:09:11 -05:00
Joel Martin
329b6db3cf Add seq and string? tests.
Issue #166
2016-02-11 09:17:49 -06:00
Dov Murik
718f8e4d6c tests/stepA: add gensym and clean or macro tests 2016-01-22 23:47:51 -05:00
Dov Murik
627bd6f766 process, tests: move atoms implementation from stepA to step6 2016-01-06 14:33:55 +02:00
Javier Fernandez-Ivern
6132da853d Fixed final bug with swap, added tests 2015-10-26 21:49:58 -05:00
Javier Fernandez-Ivern
f39c5a2633 Fixed step 6 tests 2015-10-26 21:31:44 -05:00
Javier Fernandez-Ivern
2eb2cac230 Fixed several self-hosting issues, added atom? tests 2015-10-26 20:27:29 -05:00
Joel Martin
98af2ae360 runtest.py: add --soft option, refactor test reader.
- also, mark later stepA optional as soft.
2015-10-09 09:31:29 -05:00
Joel Martin
520051615c tests: add test to make sure *host-language* is set 2015-04-03 18:31:14 -05:00
Joel Martin
7e0bb668cf Julia: self-hosting.
- fix meta and swap! functions and add missing tests
- fix eval_ast of hash-maps across all steps
2015-03-31 23:04:45 -05:00
Stephen Thirlwall
ba53efc2b5 Add test that (with-meta X ...) returns an X 2015-03-17 11:14:13 +11:00
Joel Martin
dbac60df00 All: move metadata, atoms, readline, conj to stepA.
- Move some of the more optional things (conj, readline) to stepA. All
  implementations pass step9 tests now.
- Move metadata and atoms to stepA.
- Update step9 and stepA diagrams.
2015-03-14 17:17:14 -05:00