Commit Graph

40 Commits

Author SHA1 Message Date
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
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
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
f8f0f3e889 Fixup for #1588 2022-08-29 12:29:24 +01:00
Kurtis Rader
eed6a995dd
Support comparing booleans (#1588)
Fixes #1585
2022-08-29 12:25:54 +01:00
Qi Xiao
181c4dde55 pkg/eval: Create builtin_fn_stream_test.go.
Tests for functions defined in builtin_fn_stream.go are moved there.
2022-08-28 22:08:00 +01:00
Qi Xiao
f8f60953ad Properly deprecate float64.
- Replace its use with "num" in documentation and test code.

- Add a new "inexact-num" for explicitly converting a number to inexact.

This fixes #1513.
2022-04-09 11:45:15 +01: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
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
82dda13def Fixup for #1435. 2021-12-05 20:51:17 +00:00
Qi Xiao
713a16bc6e
Merge branch 'master' into add-compare-builtin 2021-12-05 20:37:13 +00:00
Qi Xiao
b1154a95dc Fixup for #1439.
* Fix the case when start is near the overflow point and add regression tests.

* Rewrite the implementation in a less abstract way.

* Rewrite the elvdoc.
2021-12-05 20:22:44 +00:00
Kurtis Rader
2ba69c32dd Augment builtin:range to support counting down
Resolves #1436
2021-12-05 18:44:59 +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
3068edaa5f Add a builtin:compare command
Expose the default comparison function used by the `builtin:order`
command as a command in its own right. This command is useful when
writing, in Elvish, something like `builtin:order`. Such as a semantic
version comparison command.

Resolves #1347
2021-11-21 19:32:25 -08:00
Qi Xiao
a91852b0a7 Fix tests broken by last commit. 2021-10-22 17:44:57 +01:00
Qi Xiao
315a8b77e1 pkg/eval: Improve coverage of builtin_fn_container.go. 2021-09-11 14:51:26 +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
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
c39d03e973 Support all number types in the order command.
This fixes #1309.
2021-05-31 21:25:08 +01:00
Qi Xiao
e2c4030728 pkg/eval: Handle non-positive step and overflow in the range builtin. 2021-04-06 22:33:02 +01:00
Qi Xiao
5c643181a4 Cleanup, docs and tests. 2021-04-05 20:48:22 +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
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
dca782d573 pkg/eval: Document and test the ns builtin.
Also return a structured error with errs.BadValue.
2020-08-16 22:01:03 +01:00
Qi Xiao
bb24b63356 Remove builtin commands deprecated in v0.14.0. 2020-08-16 16:10:58 +01:00
Qi Xiao
270c7f230e pkg/eval: Support passing any value to "fail". 2020-05-31 13:56:59 +01:00
Qi Xiao
ff292d43ce pkg/eval: Make the sorting of "order" always stable. 2020-05-25 21:50:09 +01:00
Qi Xiao
1cd192daaf pkg/eval: Implement "order".
This fixes #651.
2020-05-25 17:45:08 +01:00
Qi Xiao
05156ea239 Add make-map command.
This fixes #943.
2020-05-05 23:23:23 +01:00
Kurtis Rader
094a03ac5b Normalize count implementation arity exception
Add some comments that clarify why the `count` implmentation does not
use the `Inputs` API. Change the mismatched arg count exception to match
that of the `Inputs` API. Add a couple more unit tests.

Resolves #966
2020-04-16 15:56:20 +01:00
Qi Xiao
feadbc2330 Introduce a new "one" builtin. 2020-01-17 09:00:23 -05:00
Qi Xiao
8a8db45230 pkg/eval: Make all take an optional argument.
Also make `all` no longer preserve byte inputs but turn them into values.
2020-01-17 08:45:34 -05: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