Commit Graph

66 Commits

Author SHA1 Message Date
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
93423d3244 Support (struct)map with 'r' or 'w' fields in redirections.
Now that pipe is a structmap and structmaps are considered indistinguishable to
normal maps, IO redirection should support arbitrary maps too.

Update the relevant section in the language spec and rewrite it a bit.
2023-07-18 17:52:06 +01: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
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
Kurtis Rader
c6e10f12a2 Some minor documentation fixes
Mostly elimination of duplicated words but also a few other fixes such
as the output of commands such as `%`.
2022-08-29 12:04:59 +01:00
Qi Xiao
68bce3b4a4 Clarify error message when writing values to port not supporting it.
This fixes #1516.
2022-06-07 20:29:34 +01: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
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
3abf7f5510 Deprecate the legacy temporary assignment syntax from 0.18.0.
This addresses #1114.
2022-01-03 00:47:24 +00:00
Qi Xiao
089752147a Fixup for #1447. 2021-12-13 01:23:14 +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
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
6822e2ca7b Deprecate the local: and up: special namespaces in 0.17.
Also deprecate the use of a leading empty namespace.

This addresses #1409.
2021-10-15 22:45:02 +01:00
Qi Xiao
6a92571a23 Check assignments to read-only variable during compilation. 2021-10-13 23:57:14 +01:00
Qi Xiao
569d73c270 Deprecate the legacy assignment form from 0.17.0.
This addresses #645.
2021-10-12 23:25:45 +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
5b490475e7 pkg/testutil: ScaledMs -> Scaled, takes a time.Duration instead. 2021-10-05 01:02:54 +01:00
Qi Xiao
fc754f6822 pkg/eval: Deliver message for finished bg job using editor notification.
This fixes #1067.
2021-10-05 00:08:14 +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
492ff19077 pkg/eval: Improve coverage of compile_lvalue.go. 2021-09-10 20:09:04 +01:00
Qi Xiao
47de83c7d1 Reorganize standard library modules.
- Move from pkg/eval/mods to pkg/mods

- Introduce mods.AddTo that adds all standard library modules

- Move epm and readline-binding into their own packages
2021-08-24 15:56:04 +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
Kurtis Rader
57cf018e06 Update unit tests that use p[rw]close
Replaces uses of the deprecated builtin `prclose` and `pwclose` commands
with `file close` in unit tests.

This also fixes one test that was not verifying what it intended due to
it's use of `.Throws(AnyError)` which was matching an Elvish error caused
by invalid command `file:prclose $p`.
2021-08-01 21:17:02 +01:00
Qi Xiao
ce08c4a7d5 Throw exception when writing values to a port without a value component.
This is done by generalizing the mechanism used to detect that the reader of
value output has terminated.
2021-06-22 00:35:30 +01:00
Qi Xiao
657b73122f Change all builtin commands writing value output to surface ReaderGone.
Also replace (*Frame).OutputChan with (*Frame).ValueOutput, which returns a
small interface for writing to the value output that is also aware when the
reader is gone.
2021-06-18 00:14:59 +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
7b66e9f104 Minor fixups for #1273.
Also fix a test broken by bad merge.
2021-05-02 00:13:22 +01:00
Qi Xiao
82f1912c5e
Merge branch 'master' into readonly-var-msg 2021-05-01 19:06:39 -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
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
Kurtis Rader
ddf9bf040e Correctly highlight read-only except var
Using a read-only variable as the target of an `except` clause should
highlight just the var name rather than the entire `try...except...`
statement.

Resolves #1258
2021-03-28 22:01:31 +01:00
Kurtis Rader
1e0885310e Include name in error msg setting a readonly var
When attempting to update a read-only var return an error struct rather
than a simple string (i.e., a Go `error` type).  This makes it possible
to include the var name in the error message.  This builds on commit
a33ecb2d that highlights the offending var name in the stack trace but
does not include the var name in the error message. With this change the
error message includes the offending var name.

Related #255
2021-03-26 18:38:22 -07:00
Qi Xiao
a33ecb2da4 When variable cannot set, point to the variable in the stack trace.
This fixes #255.
2021-02-21 11:53:05 +00:00
Qi Xiao
196eea21d4 Change module import path to src.elv.sh 2021-01-27 01:30:25 +00:00
Qi Xiao
37c3c0b0de Deprecate the use of "a=b" for non-temporary assignment in 0.15.
It is still the syntax for temporary assignment; only using it as a standalone
command is deprecated.
2021-01-19 23:28:34 +00:00
Qi Xiao
50c971e5dd pkg/eval: Split test functions. 2021-01-10 16:43:21 +00:00
Qi Xiao
d84e9801b5 Don't compile the arguments of special commands twice.
This fixes #1204.
2021-01-09 23:33:24 +00:00
Kurtis Rader
b58b495d77 Fix hang reading value channel from a redirection
Fixes #600
Fixes #1010
2020-11-07 13:52:29 -05: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
48919bcb24 pkg/: Move test utilities from util/ to testutil/. 2020-09-03 04:55:16 +01:00
Qi Xiao
0bbee3b5f4 pkg/eval: Fix the error message when using dynamic string as head. 2020-08-31 14:01:49 +01:00
Qi Xiao
1e2ead56e2 pkg/eval: Rewrite the lvalue parsing code.
Also lift the restriction on rest variables and rest arguments - they may now
appear anywhere, as long as there is only one.
2020-08-20 13:15:00 +01:00