Commit Graph

4839 Commits

Author SHA1 Message Date
Qi Xiao
ee62608e88 pkg: Move string utilities from util/ to strutil/.
Also remove unused functions.

There were two (correct) implementations of deciding whether a string has
another string as a subsequence; keep the more performant one.
2020-09-03 05:08:01 +01:00
Qi Xiao
48919bcb24 pkg/: Move test utilities from util/ to testutil/. 2020-09-03 04:55:16 +01:00
Qi Xiao
c9d037bac7 pkg/util: Remove unused DeepPrint. 2020-09-03 04:47:43 +01:00
Qi Xiao
80dcc22bc8 pkg/cli: apptest/ -> clitest/. 2020-09-03 04:44:55 +01:00
Qi Xiao
eb9638fc16 pkg/eval: Move modules into a mods directory. 2020-09-03 04:31:04 +01:00
Kurtis Rader
0f6b4bb737 Test $pwd behavior
Related #1062
Resolves #1120
2020-09-03 04:25:38 +01:00
Kurtis Rader
b5b3a0d607 go vet cleanup
Most of the code uses keyed fields in composite literals; i.e., struct
literals. However, running `go vet ./...` reports a few places that use
anonymous fields. This modifies those composite literals to use keyed
fields. This does make the code a bit more verbose without reducing
the likelihood of a bug. But it does make the code more consistent, use
best practices, and make it easier to notice if a potential problem is
introduced when running `go vet ./...` since that command now produces
no diagnostic output.

I considered adding a `make vet` target that explicitly ran

    go vet -composites=false ./...

I decided not to do that since consistently using keyed composite literals
is preferable to having a mix of keyed and unkeyed composite literals.

This also removes the unused `ExampleLoop` function which causes this
`go vet` warning:

    pkg/cli/loop_test.go:130:1: ExampleLoop refers to unknown identifier: Loop
2020-09-03 04:24:06 +01:00
Qi Xiao
e28a7d766b pkg/eval: Small fixup for ExternalCmd tests. 2020-09-03 04:16:29 +01:00
Kurtis Rader
fd64782e2c Improve test coverage of pkg/eval/external_cmd.go
Improve coverage of pkg/eval/external_cmd.go from 58.3% to 86.1% as
measured by `make test` on macOS.

This would have been a smaller change but I felt it was important to
actually validate the exception raised when an external command fails
rather than simply using `.ThrowsAny()`. That necessitated augmenting
the pkg/eval/testutils.go module.

Related #1062
2020-09-03 04:14:26 +01:00
Qi Xiao
8988d6e5f0 website/ref Document function introspection, and move exception introspection.
Also introduce the concept of pseudo-map for documenting them.

This fixes #1122.
2020-08-31 22:12:00 +01:00
Qi Xiao
6a5903df90 website/learn: Update cookbook.
This fixes #1134.
2020-08-31 21:09:40 +01:00
Qi Xiao
b1ef4b2c6d pkg/eval: Fixup for the elvdoc of the sleep command. 2020-08-31 20:27:29 +01:00
Kurtis Rader
19e158d08a Document builtin sleep and add tests
I was reviewing test coverage and noticed that the `esleep`
implementation was undocumented and had no tests. This

a) implements `sleep` and deprecates `esleep`,

b) uses the Go time.ParseDuration function rather than assuming a
simple number of seconds,

c) documents the command,

d) adds tests of the function.

Related #1062
2020-08-31 20:22:47 +01:00
Qi Xiao
1b26cdde7e website/ref/language: Small editoral changes; fix typos. 2020-08-31 15:17:00 +01:00
Qi Xiao
46dedae9fa website/ref: Restructure a large part of the language reference.
The new structure is inspired by the Go language spec. A lot of sections also
have minor updates, and some new sections have been written.
2020-08-31 14:41:44 +01:00
Qi Xiao
d98f7881eb website/ref: Drop the "the" in "the language specification". 2020-08-31 14:32:36 +01:00
Qi Xiao
26412e1284 website: Move the basic style for tables into style.css, from get/prelude.css. 2020-08-31 14:31:59 +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
89d95c17a6 pkg/ui: Do not strip unprintable characters from the prompt.
This will preserve private use characters that are sometimes used by icon fonts.
Control characters are already escaped by cli/term.Writer.
2020-08-28 22:00:40 +01:00
Kurtis Rader
eed744044c Eliminate sys.Ioctl
I started by writing tests for sys.Ioctl but after I had 100% coverage
of that function it occurred to me the function could be eliminated.

Related #1062
2020-08-27 15:51:29 +01:00
Qi Xiao
37001a42f2 language.md: Improve wording of first few sections. 2020-08-27 01:19:36 +01:00
Kurtis Rader
e25ee599db Increase options.go coverage to 100%
Related #1062
2020-08-26 20:40:22 +01:00
Kurtis Rader
2bbe6d2212 Add explicit cd unit tests
This is to ensure we have good test coverage of the `cd` implementation.

Related #1062
2020-08-26 20:34:34 +01:00
Qi Xiao
f91ed63b79 Document the support for SGR sequences in prompts. 2020-08-25 23:26:51 +01:00
Qi Xiao
d80d845706 Parse escape sequences from prompts.
This finishes the reimplementation of #1038. This fixes #814.
2020-08-25 23:04:14 +01:00
Qi Xiao
5e648ceac7 pkg/ui: Implement ParseSGREscapedText.
Part of a reimplementation of #1038.
2020-08-25 22:47:22 +01:00
Qi Xiao
9169f803ea pkg/ui: Add a Concat function for concatenating multiple Text's. 2020-08-25 22:34:19 +01:00
Qi Xiao
b6adbed317 pkg/ui: Implement StyleFromSGR in terms of a new StylingFromSGR.
Part of a reimplementation of #1038.
2020-08-25 21:17:14 +01:00
Qi Xiao
0c00a92839 Fix crash when accessing the body attribute of fn-defined functions.
This fixes #1126.
2020-08-25 20:17:21 +01:00
Qi Xiao
b2c85b7c2f pkg/eval: Add some basic benchmarks for code evaluation. 2020-08-23 17:33:54 +01:00
Qi Xiao
4a130be641 pkg/eval: Move benchmarks to separte file. 2020-08-23 16:07:11 +01:00
Qi Xiao
8b2e669a5f Remove unused code. 2020-08-23 16:04:44 +01:00
Qi Xiao
b04ea12d48 pkg/eval: Refactor effectOp and valuesOp, remove lvaluesOp.
* Make effectOp and valuesOp interfaces - implementations now handle the
  range information themselves.

* Remove lvaluesOp; it is no longer used.
2020-08-22 19:57:11 +01:00
Qi Xiao
ac4ac7f447 Update other dependencies. 2020-08-20 22:49:57 +01:00
Qi Xiao
74ed0d5c2f Update the xiaq/persistent dependency. 2020-08-20 22:48:40 +01:00
Qi Xiao
1bbb04b171 Document breaking changes in introspection of rest arguments. 2020-08-20 13:33:10 +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
Qi Xiao
ce19bca599 Makefile: Don't run go test with -race on Windows.
Running "go test -race" on Windows requires GCC, and it appears not all GCC
builds are compatible. Since we can't reliably determine whether the environment
has a good GCC for running the race detector, just don't enable it.

This resolves #1108.
2020-08-18 21:35:30 +01:00
Qi Xiao
821e414fc9 pkg/eval/errs: Change OutOfRange.Valid{Low High} to strings. 2020-08-18 21:23:26 +01:00
Qi Xiao
f2264ee4df Update reference to removed "explode" command to refer to "all" instead. 2020-08-18 21:13:59 +01:00
Kurtis Rader
da16162cc8 Increase umask code coverage from 62% to 100%
Related #1062
2020-08-18 21:13:27 +01:00
Qi Xiao
ceda0d052b Update more examples to reference new slice syntax. 2020-08-17 05:34:06 +01:00
Qi Xiao
a7934a6810 Remove references to old slice syntax, and the unimplemented "@" index. 2020-08-17 05:31:46 +01:00
Qi Xiao
cfcc53ac97 pkg/parse: Make \ a valid bareword character.
This fixes #979.
2020-08-17 05:01:53 +01:00
Qi Xiao
4659d9bcc6 Introduce a use-mod command.
This fixes #1113.
2020-08-17 00:11:25 +01:00
Qi Xiao
944948beab website/ref: Expand the doc for modules. 2020-08-17 00:08:15 +01:00
Qi Xiao
ea31426a9a pkg/eval: Refactor to reuse code between "use" and "eval". 2020-08-16 23:32:51 +01:00
Qi Xiao
ff7c500506 Deprecate the -source command. 2020-08-16 23:07:30 +01:00
Qi Xiao
735d30c0ff Introduce a new eval command.
This fixes #230.
2020-08-16 23:04:10 +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