Commit Graph

24 Commits

Author SHA1 Message Date
Qi Xiao
19bd75db57 pkg/eval: Make the peach test cases print $best-run on failure. 2023-05-08 23:34:04 +01:00
Qi Xiao
75ee4d0179 pkg/eval: Increase the base sleep time in peach's unit test to 2ms.
The previous value of 1ms caused some false positive on Cirrus's Linux ARM64 runner.
2023-05-07 22:38:22 +01:00
Qi Xiao
6ecc2b306c Fixup for #1691. 2023-05-06 23:55:34 +01:00
Kurtis Rader
91c819d5d8 Add a &num-workers option to peach
Resolves #648
2023-04-16 20:34:55 -07:00
Qi Xiao
8ed351e386 Add a new "defer" command. 2022-01-05 00:12:35 +00:00
Kurtis Rader
87656c99fa Replace AnyError in tests with a specific error
The `AnyError` placeholder error can cause tests to succeed for errors
other than what was expected. That is, the use of `AnyError` can mask
bugs in a unit test. So replace it with the specific error, or error type,
the test expects to be raised.

This does not remove the anyError structure because it is used in
the TestCase.DoesNotCompile() method. To keep the size of this change
as small as possible I want to defer updating that use to a separate
change. However, remove the public AnyError var so future test writers
don't attempt to use it.
2021-12-13 01:08:24 +00:00
Kurtis Rader
d4b4edbbbe Replace legacy lambda with new lambda examples
I was surprised to see so many legacy lambda syntax examples in the
documentation. This replaces all of them with the new syntax -- excluding
the handful of cases meant to explicitly verify the legacy form is still
valid. This also adds a link to the issue in the release notes which
documents the change in syntax.

Related #664
2021-11-28 21:30:59 +00:00
Qi Xiao
3526f0284e pkg/eval: Increase coverage of builtin_fn_flow_test.go. 2021-10-03 01:09:08 +01:00
Qi Xiao
9981b2a777 Reduce the flakiness of TestPeach with some random jitter.
There was a recent failure of the test that checks peach is
nondeterministic: https://github.com/elves/elvish/runs/2926941131

The failure can be reproduced reliably when setting GOMAXPROCS=1.
However, GitHub Action's Windows runner has two CPU cores, which means
GOMAXPROCS should be 2. Presumably, during that particular one, one of
the cores is occupied by another process, so Go had to run the
goroutines in order on one CPU core.

Go's time.Sleep yields the current goroutine and allow other scheduled
goroutines to run on the same thread. As a result, adding a random
jitter guarantees nondeterminism in execution order, even if only one
CPU core is available to execute threads.

Also run the nondeterminism check in an infinite loop.
2021-06-28 00:46:27 +01:00
Qi Xiao
9361832251 Fixup for #1310 2021-05-31 22:13:24 +01:00
Kurtis Rader
8a92716bd9 Add test coverage of peach
This also documents the behavior of `break` and `continue` when used in
the function passed to `peach`.

Related #1234
2021-05-17 19:28:45 -07:00
Qi Xiao
da67ba8a4a Use machine word (int) instead of int64 for fixnum. 2021-04-04 13:37:38 +01:00
Qi Xiao
4612b58759 Support exact integer and rational numbers. 2021-04-04 00:58:53 +01:00
Qi Xiao
196eea21d4 Change module import path to src.elv.sh 2021-01-27 01:30:25 +00:00
Qi Xiao
50c971e5dd pkg/eval: Split test functions. 2021-01-10 16:43:21 +00:00
Qi Xiao
90a99c1792 pkg/eval/evaltest: Consolidate all the Throws* methods into one. 2020-09-04 20:31:47 +01:00
Qi Xiao
bb122024dd pkg/eval: Move test framework into new evaltest package. 2020-09-03 06:51:21 +01:00
Qi Xiao
1f562505f3 Rework the API for introspecting exception causes.
* Use a "type" field to identify the type, instead of predicates in the exc:
  module.

* Make the reason values behave more like structmaps, including a Repr that
  mimics a map.

This fixes #208.
2020-06-30 22:27:07 +01:00
Qi Xiao
270c7f230e pkg/eval: Support passing any value to "fail". 2020-05-31 13:56:59 +01:00
Qi Xiao
92cb80d89a Support rethrowing an exception with "fail".
This fixes #941.
2020-05-05 00:43:50 +01:00
Qi Xiao
ba7bedcbd9 Support \r\n everywhere output is processed as individual lines.
This fixes #970.
2020-05-03 23:30:23 +01:00
Qi Xiao
bd2ffa75cc pkg/eval: Make exception matching more explicit.
Don't match implicitly by Cause. Instead, use a new .ThrowsCause method to
explicitly match for the cause.
2020-04-10 20:55:31 +01:00
Qi Xiao
ca945dcb7f pkg/eval: TestCase.Errors{With,} -> Throws{,Any}.
This is in preparation for supporting compilation errors. Also did some
cleanups.
2020-01-08 23:09:19 +00:00
Qi Xiao
e45fdf7228 Move all libraries to new pkg/. 2019-12-23 20:00:59 +00:00