Commit Graph

694 Commits

Author SHA1 Message Date
Qi Xiao
155ea5acb1 pkg/eval: Bump the sleep time in the test for peach more.
Another failure in the Linux ARM64 runner: https://cirrus-ci.com/task/6301954620522496
2023-05-20 11:55:31 +01:00
Qi Xiao
2fe4512556 pkg/eval/vals: Make Repr sort map keys before printing.
This addresses #1495.
2023-05-20 10:52:52 +01:00
Qi Xiao
7c0c3eb82d pkg/eval/vals: Correct the godoc of Cmp. 2023-05-20 10:20:48 +01:00
Qi Xiao
c71995ba9a pkg/eval: Add tests for "order &total". 2023-05-19 17:27:37 +01:00
Qi Xiao
058f9818ae pkg/eval: Fix the equality test in "has-value".
Previously Go's == was used to test for equality when the container is not a
map, which is more strict when Elvish's normal equality test. For example,
"has-value [[foo]] [foo]" used to output false, rather than the expected true.
2023-05-19 17:25:36 +01:00
Qi Xiao
3f4bbff9c5 pkg/eval: Add option for total order to the order and compare commands.
The same code will be used to sort map keys when printing maps.

This addresses #1495.
2023-05-18 23:21:18 +01:00
Qi Xiao
25e27d6bb6 pkg/eval/vals: Make Cmp(a, b) return CmpEqual if Equal(a, b).
Also match the order of branches in Cmp and Equal.
2023-05-18 10:45:42 +01:00
Qi Xiao
1e249ed7fb pkg/eval.cmp -> pkg/eval/vals.Cmp. 2023-05-18 10:31:31 +01:00
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
0557e2a3be pkg/eval/evaltests: Make APIs of special matchers functions. 2023-05-08 23:27:53 +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
ae087dc1e4 pkg/eval: Don't use the new context.Cause API.
Elvish should still be buildable with Go 1.19.
2023-05-07 22:37:08 +01:00
Qi Xiao
f54fe608e8 Clean up some code from adding Context to Frame. 2023-05-07 21:49:27 +01:00
Qi Xiao
da576e221c pkg/eval: Use a Context inside Frame to pass interrupts. 2023-05-07 21:44:28 +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
89bf04a802 pkg/eval: Construct ui.Text using the functions from the ui package.
This fixes #1668, because the crashing listbox rendering code uses "len(line) >
0" (where line is a ui.Text) to test whether it is non-empty. This test doesn't
work with the ui.Text constructed using "styled ''", which creates a ui.Text
with one empty segment.

The functions from the ui package are guaranteed to never return such ui.Text
instances, so switching the implementation of the styled builtin to functions
from the ui package fixes this.
2023-03-14 21:47:38 +00:00
Qi Xiao
0adf0ec147 Use the unix build tag.
The unix build tag is supported by Go 1.19.
2023-03-03 00:01:26 +00:00
Qi Xiao
67db2194c8 pkg/eval: Support slashes in relative command paths on Windows.
This fixes #1660.
2023-02-27 22:57:02 +00:00
Qi Xiao
34b115d7af Bump prog.DeprecationLevel to 19.
Remove use of float64 in tests, except for one that tests that it is deprecated.
2023-02-27 00:00:12 +00:00
Qi Xiao
5e1d0b6d3d Remove support for the "except" keyword.
It has been superseded by "catch" since the 0.18.0 release.
2023-02-26 23:55:48 +00:00
Qi Xiao
3845a2cf7f Expose stack traces in exceptions as opaque values.
Also document the correct way to compare the causes of exceptions.

This fixes #1632.
2023-02-26 23:52:26 +00:00
dunsany
9a26d6c645
Various has-key fixes (#1647)
* Correct slice indexing convention in code comment

A colon is not supported.

* Add more key slices tests

* Unify `has-key` tests with those from `pkg/eval/vals/has_key_test.go`

* Fix key slice format in documentation

Fixes #1646.

* Fix missing bracket

* Fix indexing

* Add more key slices `has-key` tests

* Fix `has-key` test expected value
2023-02-26 20:49:31 +00:00
dunsany
4172348398 Fix exception capture example 2023-02-04 14:37:10 +00:00
Qi Xiao
97a73e2d95 evaltest.capturePort -> eval.CapturePort.
Also rename the original eval.CapturePort to ValueCapturePort.
2023-01-15 16:44:25 +00:00
Qi Xiao
c7ed16d3cb pkg/eval/evaltest: Print byte output diff with go-cmp. 2023-01-15 16:44:25 +00:00
Qi Xiao
6166c13409 Remove superfluous content from example for the deprecate builtin. 2023-01-13 00:21:33 +00:00
Qi Xiao
0b0f5ba867 Add a new "conj" command for appending values to a list. 2023-01-04 18:57:08 +00:00
Qi Xiao
24640d3241 pkg/eval: Move tests of builtin commands to match implementation files. 2023-01-04 18:37:47 +00:00
Qi Xiao
de3a7fd1b3 Standardize spelling: UNIX -> Unix.
https://en.wikipedia.org/wiki/Unix#Branding contains a history of the spelling.
Follow Wikipedia in using Unix instead of UNIX.
2023-01-04 18:09:11 +00:00
Qi Xiao
7cbbd84b55 pkg/parse/cmpd: Handle nil in Primary.
This fixes a panic caused by "try { } catch".
2023-01-02 18:49:58 +00:00
Qi Xiao
08007a52ce website/cmd/md2html: Support implicit link targets to elvdoc sections.
For example, [`put`]() links to the elvdoc for "put".

Also remove the @cf macro now that implicit targets make it easier to link to
other elvdoc sections.
2023-01-02 02:36:58 +00:00
Qi Xiao
fcc6d23f14 pkg/mods/doc: Convert links to language.html to absolute links.
For example, a link to language.html#number is converted to point to
https://elv.sh/ref/language.html#number instead. Such links are quite common in
elvdocs.

Also convert all link destinations that use ./language.html to use language.html
instead, and add a check in tools/check-disallowed.sh to ensure that remains the
case.
2023-01-02 01:35:41 +00:00
Qi Xiao
629be7e297 Use path:is-dir in the example for $pwd. 2022-12-30 18:36:31 +00:00
Qi Xiao
7c52dd9545 Fix the example for $pwd to use new temporary assignment syntax. 2022-12-30 18:30:47 +00:00
Qi Xiao
833569303c Fixups for #1629. 2022-12-28 12:42:31 +00:00
Manuel Mendez
9fae00d125 eval: Add DeleteGlobal
Will be use by edit module soon.
2022-12-28 12:27:17 +00:00
Manuel Mendez
b178367ca7 eval: Fix godocs with wrong function name 2022-12-28 12:27:17 +00:00
Manuel Mendez
1ada9a5e22 ns: Add Ns.clone method
Does what it says on the tin.
2022-12-28 12:27:17 +00:00
Qi Xiao
5e6954dbf3 Add a doc: module for accessing documentation of Elvish modules.
This fixes #1432.
2022-12-26 21:36:07 +00:00
Qi Xiao
5a237d7888 pkg/eval: When compiling, emit autofixes for using unimported builtin modules. 2022-12-11 14:21:09 +00:00
Qi Xiao
78862465a4 pkg/diag: Include line:col of start position in Error and Show methods.
The Error methods used to show the start and end indices, while the Show methods
used to show line ranges.

Showing line:col of the start position seems to be pretty standard; both Go and
Rust do that.

I tried including the line:col of the end position too, but can't find a good
enough format.
2022-12-08 19:07:18 +00:00
Qi Xiao
7e6bd950b1 pkg/diag: Increase test coverage. 2022-11-30 12:57:02 +00:00
Qi Xiao
121509d8d2 pkg/eval: Preserve all compilation errors.
Multiple compilation errors are packed using diag.PackCognateErrors, like parse errors.
2022-11-30 01:40:03 +00:00
Qi Xiao
94ab1b5390 Generalize parse.Errors and move it to diag.
This generalized type will be used to pack multiple compilation errors.
2022-11-30 01:05:16 +00:00
Qi Xiao
3847235a14 pkg/diag: Split Errors into another package.
The Errors function is not related to diag.Error, so keeping it in the same
package is confusing.

Also unexport the MultiError type. This allows its Error method to be
simplified, as it can assume that it always contains at least 2 errors.
2022-11-29 22:13:02 +00:00
Qi Xiao
69715b05fe pkg/eval: Don't use panics for propagating compilation errors.
This also enables saving multiple compilation errors.
2022-11-29 21:17:13 +00:00
Qi Xiao
ff0feb4311 pkg/eval: Refactor index tracking out of argsWalker.
Also redesign the internal API a bit, and rename to argsGetter.
2022-11-29 21:17:07 +00:00
Qi Xiao
d3eda3dc88 pkg/eval: Remove leftover registration of time commands. 2022-11-26 15:22:18 +00:00
Qi Xiao
4520fc7fd4 pkg/eval: Move time-related builtins to separate file. 2022-11-26 10:41:58 +00:00