Qi Xiao
a1b30deb86
pkg/eval/evaltest: Rename TestWithFullSetup -> TestWithSetup.
...
The old TestWithSetup is now more accurately called TestWithEvalerSetup.
2023-07-22 23:04:18 +01:00
Qi Xiao
6992c0b693
Make pseudomaps print like [^tag &key=value].
...
Also make file:pipe output a struct map rather than a pseudomap.
2023-07-17 23:41:43 +01: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
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
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
93e28d846b
Fixup for #1618 .
...
- Simplify the matcher for compilation errors.
- Various stylistic fixes.
2022-11-20 16:39:01 +00:00
Kurtis Rader
358e52a7f5
Make testing compilation errors more deterministic
...
A year ago I submitted a change to replace AnyError with tests for specific
errors (see https://github.com/elves/elvish/commit/87656c99 ). This does
something similar for DoesNotCompile. This ensures the test does what
is implied and makes correlating specific unit tests with compilation
errors easier.
This includes a couple of changes to compilation error messages to improve
readability (IMHO) but those are not the primary purpose of this change.
Related #1560
2022-11-20 16:33:29 +00:00
Qi Xiao
3ff0e4bcd9
pkg/eval: Check whether variable name is empty when parsing lvalue.
...
This fixes #1560 .
2022-10-03 04:34:05 +01:00
Kurtis Rader
e896ac3c0e
Improve some compilation errors ( #1617 )
...
Quote variable names appearing in some compilation errors to improve
the clarity of those errors.
2022-10-03 04:22:46 +01:00
Qi Xiao
4afbb71c07
Move pkg/testutil/must.go to a new pkg/must.
2022-06-20 20:29:14 +01:00
Qi Xiao
d2c005df45
pkg/eval: Test import of module with invalid UTF-8.
2022-06-20 00:14:25 +01:00
Qi Xiao
f42c2dda61
Make init value of $f~ actually identical to $nop~.
...
This fixes #1519 .
2022-06-07 20:20:00 +01:00
Qi Xiao
26a66284a9
Fixup for #1551 .
2022-06-05 16:01:10 +01:00
Tw
d27610b3e4
Fix undefined temporary environment restoring issue
...
Close #1536
Signed-off-by: Tw <tw19881113@gmail.com>
2022-06-05 15:41:19 +01:00
Kurtis Rader
14321f9e82
Make parse.Source naming more consistent
...
Fixes #1545
2022-05-29 17:36:29 +01:00
Qi Xiao
aa6d5a6257
Re-enable staticcheck, and fix issues it found.
2022-05-22 11:57:38 +01:00
Qi Xiao
dd3950cec0
Use the new testutil.Set in more places.
2022-04-11 21:55:59 +01:00
Qi Xiao
51e4d97568
interface{} -> any now that Elvish requires Go 1.18.
2022-03-20 16:17:19 +00:00
Qi Xiao
957c8a7521
evaltest: Check that stderr is empty if PrintsStderrWith is not called.
...
Among other things, this will check for deprecation warnings. Also fix test code
that uses deprecated features.
2022-03-20 09:50:05 +00:00
Qi Xiao
e894ae5f82
Improve the syntax of "try".
...
* Require at least one of "except" or "finally" to be present. This fixes #1424 .
* Rename "except" to "catch". The former will be deprecated from 0.18.0. This
addresses #1497 .
2022-03-01 13:57:00 +00:00
Qi Xiao
d7a9d38731
pkg/eval: Remove reference to the now-gone local: scope.
2022-02-20 23:30:47 +00:00
Qi Xiao
be1e144b45
Remove support for the "local:", "up:" and ":" special namespaces.
...
This fixes #1409 .
2022-01-03 00:47:41 +00:00
Qi Xiao
3dd3b780b9
Remove legacy assignment syntax.
...
This fixes #645 .
2022-01-03 00:47:41 +00:00
Qi Xiao
4fcffc5671
Remove most uses of the legacy assignment syntax.
...
The remaining few uses are in some of the tests, which will be removed later.
This addresses #645 .
2022-01-03 00:47:41 +00:00
Qi Xiao
653c9f9d0f
Remove dir-history, deprecated since 0.17.0.
2022-01-03 00:47:41 +00:00
Qi Xiao
a8844a34f8
Check that blocks in control flows don't have arguments or options.
...
It is now a compile-time error if they do. This fixes #1456 .
2021-12-30 13:49:48 +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
Qi Xiao
973fe39798
Implement the tmp special command.
...
This addresses #1114 .
2021-12-09 22:12:38 +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
Kurtis Rader
8faf8930b3
Add use
unit tests and tweak documentation
...
This explicitly tests a common error case not currently verified by the
existing unit tests. Thus improving test coverage by one line. :-)
2021-11-14 16:17:51 +00:00
Qi Xiao
d71e52cbd7
Refactor the API of eval.NsBuilder to be completely based on methods.
2021-10-23 21:44:11 +01:00
Qi Xiao
b570b2f0b5
pkg/eval: Clean up the Ns type a bit.
2021-10-23 18:18:31 +01:00
Qi Xiao
6a7d99041d
pkg/eval: Require the variable used in "set" to already exist.
...
This has always been the documented behavior, but up until this point, "set"
actually behaved like the legacy assignment form, which creates the variable if
it doesn't exist yet.
This fixes the discrepancy. Addresses #645 .
2021-10-10 14:31:09 +01:00
Qi Xiao
862cf5619d
Support turning off implicit external command resolution.
...
See documentation in website/ref/language.html.
This fixes #978 .
2021-10-07 01:21:28 +01:00
Qi Xiao
e299010be8
pkg/eval: Export the config fields and remove access methods.
2021-10-05 00:53:38 +01:00
Qi Xiao
c6d9ebc389
Add special command "coalesce".
...
This fixes #1404 .
2021-10-03 19:14:44 +01:00
Qi Xiao
0571db69e2
Remove commands deprecated in 0.16.0, and deprecate dir-history.
2021-10-03 16:47:51 +01:00
Qi Xiao
cd62d565ab
pkg/eval: Small test coverage improvements.
2021-10-03 01:54:07 +01:00
Qi Xiao
1cc3faa15a
Make use of (*testing.T).Cleanup in more places.
2021-08-06 23:49:11 +01:00
Qi Xiao
e9d328aa16
Make use of (*testing.T).Cleanup for test cleanups.
...
This allows turning the following pattern in tests:
value, cleanup := setupSomething()
defer cleanup()
into the following:
value := setupSomething(t)
2021-08-06 23:21:23 +01:00
Qi Xiao
adf8066819
pkg/testutil: Make MustWriteFile easier to use.
...
The function now take a string for the file content, and always uses 0600 for
file permission.
2021-08-06 21:38:37 +01:00
Qi Xiao
2d09e1a500
Implement XDG directory support.
...
Tests will be added in a followup commit before this branch is merged.
This addresses #383 .
2021-07-10 02:20:59 +01:00
Qi Xiao
82b9bddb15
Test almost all commands correctly bubble output errors.
...
Also make the helper thatOutputErrorIsBubbled more precise by matching for the
exact error that is thrown.
2021-06-24 23:24:43 +01:00
Qi Xiao
4776c16b2f
Add more test for special forms.
...
Plus some minor test-related changes.
2021-06-20 18:18:45 +01:00
Kurtis Rader
9a576529a3
Replace ErrArgs with more specific errors
...
This also replaces the slightly awkward "arguments here" reason with
"argument count" as the "what" for a typical errs.ArityMismatch
exception. It also reformats most of the constructors so that the "what"
is on the same line. This makes `grep errs.ArityMismatch **.go` more
useful as a result.
2021-06-13 22:42:04 +01:00
Qi Xiao
9cd90c49bb
Minor fixup for #1274 .
2021-05-02 00:22:28 +01:00
Qi Xiao
698d55ef07
Merge branch 'master' into issue-1248
2021-05-01 19:17:17 -04:00
Qi Xiao
c30a6a2fbe
Remove support for using a lone "a=b" for assignment.
2021-04-08 23:57:40 +01:00
Qi Xiao
b53a92b964
Remove all builtin commands deprecated since 0.15.0.
2021-04-08 23:07:50 +01:00