Commit graph

1644 commits

Author SHA1 Message Date
Christophe de Dinechin
2dbbec4ad7 Release 0.6.4 "Healing": Testing and fixes
This release focuses on heavy testing of the new variable-precision
decimal stack. Adding tests also means finding bugs.

Another significant change is support for fixed-precision
hardware-accelerated floating point, using 32-bit and 64-bit IEEE754
binary floating-point representation. Since this uses a binary format,
some decimal values do not map to decimal correctly. For example,
displaying 1.2 with a large number of decimals will show residue,
because 1.2 does not have an exact (zero-terminated) representation in
binary.

New features:

* plotting: Make refresh rate configurable
* menu: Add `/` key to `FractionsMenu`
* hwfp: Add support for hardware-accelerated floating-point
* menus: Add hardware floating-point flag to `MathModesMenu`
* ui: Allow multiple uses of `.` to insert DMS separators
* HMS: Editing of HMS values in HMS format

Bug fixes:

* stats: Fix crash on `variance` with single-column statistics
* algebraic: Clear error before evaluating the function
* functions: Correctly emit a type error for non-algebraics
* ui: Make sure we save stack if closing the editor
* logical: Fix mask for rotate left with 64-bit size
* logical: Make sure we save args for single-argument logicals
* flags: Update flags on `FlipFlag`, consume them from `BinaryToFlags`
* stack: Show multi-line objects correctly
* lists: Returns `Bad argument value` for index with bad arguments
* lists: Return an empty list for tail of empty list
* arithmetic: `→Frac` should not error on integers
* power: Do not shut down during `WAIT` if on USB power

Improvements:

* menu: Shorten the labels `→QIter` and `→QPrec` to avoid scrolling
* stack: Avoid running same code twice on simulator
* ids: Add aliases for hardware floating point
* functions: Optimize abs and neg
* ui: Replace calls to `rt.insert` with calls to `insert`
* menu: Reorganize fractions menu
* dms: Do the DMS conversion using fractions
* list: Adjust multi-line rendering
* copyright: Update copyright to 2024
* text: Return null text when indexing past end of text

Testing:

* tests: Increase the delay for help to draw
* tests: Add tests for hardware-accelerated floating-point
* tests: Add shifts and rotate tests
* tests: Check flag functions
* tests: Test DMS and HMS operations
* tests: Add test for `integrate` using decimal values
* tests: Test multi-line stack display
* tests: Add tests for `GETI`
* tests: Min and max commands
* tests: Repair last regression test
* tests: Check behaviour of 0^0
* tests: Avoid string overflow in case of very long message

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 01:12:46 +01:00
Christophe de Dinechin
c7be6b14ec stats: Fix crash on variance with single-column statistics
When doing the sum, we were setting the result as a null pointer,
and collapsing all later results as a consequence.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
41ddcae6b6 tests: Increase the delay for help to draw
When running the tests under load, we frequently have issues with the
help tests failing. This is probably due to the time given to draw the
help file being a little too short.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
961b976d03 algebraic: Clear error before evaluating the function
Make sure we do not propagate errors when calling the function to
evaluate, so that the error does not block arithmetic evaluations.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
aed8e8da2e menu: Shorten the labels →QIter and →QPrec to avoid scrolling
Avoid scrolling when displaying the fractions menu by shortening the
labels for the `FractionIterations` and `FractionDigits` settings.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
421f3a3263 menu: Add / key to FractionsMenu
Add `/` to make it easy to enter values such as `1/4` from the
command-line, e.g. when entering complex numbers

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
b602b45314 plotting: Make refresh rate configurable
In order ot make it easier to see plotting as it happens, make refresh
rate for plotting reconfigurable with the `PlotRefreshRate` setting.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
30a30b1c42 stack: Avoid running same code twice on simulator
The creation of the output was done twice when running on simulator.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
70cf6c2fcb menus: Add hardware floating-point flag to MathModesMenu
Make it easier to find, without having to go through the catalog.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
d6ff91a05d ids: Add aliases for hardware floating point
This is simply to make testing easier.
The short aliases, `HFP` and `SFP`, are likely to be discarded.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
d580089be9 functions: Optimize abs and neg
Optimize `abs` and `neg` functions which can be simplified in almost
all cases without invoking the complex "function" mechanism.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
f7a7790294 functions: Correctly emit a type error for non-algebraics
Correctly emit a type error when running `sin` with a bad type.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
4794b3ca63 tests: Add tests for hardware-accelerated floating-point
Add tests checking functions using `float` and `double` formats.
Also add tests running variable-precision code at 120 digits.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
c12d27ac8b hwfp: Add support for hardware-accelerated floating-point
The hardware-accelerated floating-point support in the ARM chip is
about 2000 faster than the variable-precision decimal floating point
implementation. It makes sense to use it.

See numbers recorded in `doc/6-Performance.md` for details.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
47766e79cf tests: Avoid string overflow in case of very long message
When we have a very long message, we were moving `pad` beyond the end
of the padding string. This actually happens for a few rare parsing
tests where the command name is very long, so the overflow check is
necessary.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-02-05 00:24:27 +01:00
Christophe de Dinechin
72b7526149 ui: Make sure we save stack if closing the editor
If we type `#1234` and then hit the `F1` key in the `BasesMenu`, the
editor is closed, and we need to save last arguments and undo stack.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
9aed0ebca7 logical: Fix mask for rotate left with 64-bit size
Rotating left with 64-bit size would return 0, because the bit mask
was incorrectly set to 0.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
d60f99a306 logical: Make sure we save args for single-argument logicals
Operations like `ShiftLeft` need to save the stack and last args.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
cb6fd40e5b tests: Add shifts and rotate tests
Add tests for shift and rotate with both small sizes (32, 64, 16 and
13 bits) and for larger sizes (72 and 128 bits).

Fixes: #759

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
f85bb0876a flags: Update flags on FlipFlag, consume them from BinaryToFlags
The `FlipFlag` command was not writing the flag state, in effect doing
nothing. Setting the `write` variable ensures that the state is
updated.

The `BinaryToFlags` command was leaving the flags value on the stack
instead of dropping it on success.

Fixes: #800

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
b94b667e1e tests: Check flag functions
Check the various flag functions

Fixes: #776

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
897f139239 ui: Replace calls to rt.insert with calls to insert
In order to correctly move the selection, it's important to call
`insert`, which knows how to update it, instead of `rt.insert`, which
does not. This also removes a number of explicit `cursor` updates.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
0fb39d1194 ui: Allow multiple uses of . to insert DMS separators
Hitting `.` on an existing decimal separator inserts `°`.
Hitting `.` again reverts to `.`.

Hitting `.` after entering a decimal part inserts `′`, and the next
one inserts `″`. This will replace `.` with `°` if necessary.

Fixes: #799

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
29f491a268 HMS: Editing of HMS values in HMS format
Parse degree/minutes/second values as fractions

We convert HMS to degrees/minutes/seconds for editing because `:` is
already reserved for tags, and would cause syntax ambiguities.

This is necessary for #799

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
d137a46ede tests: Test DMS and HMS operations
Add tests for basic DMS and HMS operations

Fixes: #793

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
431eb1b1cb menu: Reorganize fractions menu
Reorganize fraction menu to make common operations easier to access.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
2b82dd7c55 dms: Do the DMS conversion using fractions
Avoid rounding errors for DMS display using fractions for rendering.
Convert to fraction before attaching unit in →HMS.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
fc76ba4c5c tests: Add test for integrate using decimal values
The `integrate` test is very slow when given polynomials as integrand
and integers as bounds, because it computes everything using large
fractions, and this is quite expensive. Add a test that does it with
decimals and runs much faster.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
85fbdd84c9 tests: Test multi-line stack display
Check that multi-line stack display works as intended.

Fixes: #788

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
6d6e88f057 list: Adjust multi-line rendering
When using single-line rendering, the `wantCR()` calls would still
cause us to insert undesirable newlines.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-24 12:31:21 +01:00
Christophe de Dinechin
ca6614e4f2 stack: Show multi-line objects correctly
Multi-line text and multi-line objects (e.g. matrices) should show
correctly according to the multi-line settings.

Fixes: #479

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-23 12:02:46 +01:00
Christophe de Dinechin
510b077b17 copyright: Update copyright to 2024
Update copyright to 2024.
Update About text to include the same details as in `VERSION`
Shorten `VERSION` text so that it shows multi-line when no menu is active.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-23 12:01:44 +01:00
Christophe de Dinechin
27015d924b tests: Add tests for GETI
Add tests for `GETI`, which found two bugs.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-22 20:51:20 +01:00
Christophe de Dinechin
1d643e6892 text: Return null text when indexing past end of text
When indexing past the end of a text, return a null pointer.
This allows `GETI` to correctly wrap around.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-22 20:50:49 +01:00
Christophe de Dinechin
f7e6135f47 lists: Returns Bad argument value for index with bad arguments
When we get a bad arguent value, return the same error as the HP50G
(although an index error would seem more appropriate).

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-22 20:48:02 +01:00
Christophe de Dinechin
ee6cd52ca0 lists: Return an empty list for tail of empty list
The HP50 returns `{}` for the `tail` of an empty list. Follow suit.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-22 20:47:17 +01:00
Christophe de Dinechin
3684b70f80 tests: Min and max commands
Test the `min` and `max` commands. The interesting cases are related
to type handling, e.g. rejecting mixed types or preserving all
arithmetic types.

Fixes: #786

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-22 19:37:38 +01:00
Christophe de Dinechin
54244e3297 tests: Repair last regression test
The last regression tests was failing because `XSHIFT` was incorrectly
clearing the `alpha` settting.

Add special keys to reach any of the shift states, e.g. `ALPHA_LS` for
`ALPHA` with left shift.

Fixes: #796

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-22 19:26:45 +01:00
Christophe de Dinechin
917a5ad076 arithmetic: →Frac should not error on integers
Integer values were not handled by `algebraic::decimal_to_fraction`,
leading to an incorrect type error.

Fixes: #797

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-22 19:09:42 +01:00
Christophe de Dinechin
1b25ab65fa tests: Check behaviour of 0^0
There are two possible results for 0^0, depending on the
`ZeroPowerZeroIsUndefined` / `ZeroPowerZeroIsOne` flag.

Fixes: #780

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-22 11:40:59 +01:00
Christophe de Dinechin
fa4c4fae4d tests: Avoid string overflow in case of very long message
When we have a very long message, we were moving `pad` beyond the end
of the padding string. This actually happens for a few rare parsing
tests where the command name is very long, so the overflow check is
necessary.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-22 11:26:34 +01:00
Christophe de Dinechin
60edbfdadf power: Do not shut down during WAIT if on USB power
When we are on USB power, we can wait forever, drawing very little
power, preserving whatever is shown on screen.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-22 11:24:44 +01:00
Christophe de Dinechin
90c30ccab8 Release 0.6.3 "Come and See": Repair test suite
The focus of this release was to reactivate the test suite and fix the
problems that were found activating it.

[![Recording of a full run of the test suite](https://img.youtube.com/vi/aHW2GcX5S6o/maxresdefault.jpg)](https://www.youtube.com/watch?v=aHW2GcX5S6o&list=PLz1qkflzABy-Cs1R07zGB8A9K5Yjolmlf)

New features:

- HMS and DMS operations
- unit: Rendering of `dms` and `hms` units
- Allow `·` as a multiplication sign in equations
- ui: Display 'E' cursor inside parentheses
- graphics: Accept based integers as position for `DrawText`
- complex: Add setting to switch between `2+3i` and `2+i3`.

Bug fixes:

- decimal: Fix precision loss for addition with carry
- Base: limit range of bases to 2-36
- files: Do not add a trailing zero when reading a text file
- decimal: Adjust `MinimumSignificantDigits` behaviour
- units: Do not auto-simplify `1.0` during conversion
- decimal: Normalize parsed numbers
- solver: Fix sign error in epsilon exponent for solve/integrate
- parser: Accept `x!` as input
- simulator: Avoid faulty break-through in switch statement
- complex: Make tag higher-priority than complex
- editor: Adjust cursor and select correctly during replace
- decimal: Fix display of 0.2 in NoTrailingDecimal mode
- complex: Save `this` in a GC pointer when it can move
- arithmetic: Do not fail because of surrounding error
- decimal: Clamp int32 conversions from decimal
- commands: Parse `exp10` correctly in expressions
- decimal: Avoid infinite loop computing `expm1`
- ids: Do not allow parsing of structures
- dmcp: Make sure the tests don't block on `wait_for_key`
- decimal: Use correct angle unit for negative gamma values

Improvements:

- settings: Add classes that save/restore a given setting
- Add `XSHIFT` to shift to XSHIFT state directly
- Add NOSHIFT constant to simplify test writing
- ui: Add a variant of `close_editor` without trailing zero
- decimal: Cache gamma_ck values (accelerate gamma and lgamma)
- Replace magic constant `-1` with `EXIT_PGM`
- doc: Record performance data for 1000 iterations of SumTest
- decimal: Add tracing for gamma / lgamma function

New tests:

- Add tests for arithmetic truncation on short bitsizes
- Add tests for on-line help
- Add test for plotting flags
- Add test for Unicode to text conversions
- Add test for rectangular complex display options
- Add tests for plot scaling functions
- Add tests for the sorting functions
- Add test for parsing text with quotes inside
- Add test for file-based `STO` and `RCL`
- Add test for 2^256 computation (buf #460)
- Fix indentation of `[PASS]` or `[FAIL]` for UTF8 characters
- Add tests for units and conversions
- Add a keyboard test checking the single-colon insert in text
- Add test for i*i=-1 auto-simplification
- Add basic test for numerical integration
- Add test for fraction formats
- Add solver test
- Add missing tests
- Add test for immediate `STO` (#390)
- Add tests for the `Cycle` command
- Add test for catalog feature
- Add test for "smart" keyboard shortcuts introduced in 0.4.6
- Add regression test for #371
- Add tests for editor operations
- Test stack operations
- Add test for `GXor`, `GOr` and `GAnd`
- Add test for `ResetModes`
- Add plotting test for every decimal function
- Add image checking for graphical tests
- Add tests for graphic and text drawing commands
- Make it possible to individually run tests.
- Add plotting tests
- Add test parsing the various spellings for commands

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-22 00:18:41 +01:00
Christophe de Dinechin
ee4b27dda5 tests: Add tests for arithmetic truncation on short bitsizes
Regression check for the fix in #624

Fixes: #789

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-21 23:42:35 +01:00
Christophe de Dinechin
969c5325a3 tests: Add tests for on-line help
Add tests for the various on-line help features.

Fixes: #791

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-21 23:28:30 +01:00
Christophe de Dinechin
2d0d129ee2 test: Add test for plotting flags
Check the `CurveFilling` and `NoPlotAxes` setting, as well as numeric
flags -31 and -29.

Fixes: #778

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-21 21:49:53 +01:00
Christophe de Dinechin
6323e12b50 tests: Add test for Unicode to text conversions
Add tests for `NUM`, `CHR` and Unicode text conversion.

Fixes: #783

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-21 19:14:17 +01:00
Christophe de Dinechin
0698cf6665 tests: Add XSHIFT to shift to XSHIFT state directly
Add XSHIFT pseudo key to shift to XSHIFT state directly.

Fixes: #794

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-21 19:14:11 +01:00
Christophe de Dinechin
93fcd8c32a tests: Add test for rectangular complex display options
Test the `ComplexIBeforeImaginary` and `ComplexIAfterImaginary`
settings

Fixes: #792

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-21 18:19:24 +01:00
Christophe de Dinechin
216fb342b0 Add tests for plot scaling functions
Add tests for `pmin`, `pmax`, `xrng`, `yrng`

Fixes: #777

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-01-21 18:19:24 +01:00