Commit graph

1863 commits

Author SHA1 Message Date
Christophe de Dinechin
0df86b131f simulator: Avoid crash rendering %t in recorder
If we print a really large value, we need to cut off what we print.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-28 23:51:08 +01:00
Christophe de Dinechin
2fad76ce6c graph: Sum and product graphical rendering
Render sum and product grpahically on the stack.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-28 23:51:08 +01:00
Christophe de Dinechin
55b7d4152e functions: Add sum and product functions
Add "real" n-ary functions for `sum` and `product`.

Note that the HP50G does symbolic pre-computation for sums, with the
interesting side effect that it may give "strange" results for empty
sums. For example, `I 10 1 'I^3' Σ` gives `-2024`, which is a bit
suprising.

The rationale, I believe, is that `I A B 'I^3' Σ` is first simplified
as `'(B^2+2*B^3+B^4-A^2+2*A^3-A^4)/4'`, which gives the negative
result when `A>B`.

This behaviour is not replicated in DB48X, which follows the HP48
model, where a sum between 10 and 1 returns 0, not a negative value.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-28 23:51:08 +01:00
Christophe de Dinechin
fb6c7b69e2 graph: Graphical rendering of combinations and permutations
Render `comb` and `perm` using the traditional mathematical notation.

Note that this is different from the way the HP48 and HP50G do it:

- The HP48 gives an `Undefined name` error for `N M COMB`

- The HP50 expands this to a factorial-based expression.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-28 23:51:08 +01:00
Christophe de Dinechin
838938336e menus: Place ListMenu as a keyboard-accesisble menu
Remove the `DataMenu`.

Replace `PrintMenu` with `ListMenu` as keyboard-accessible menu
(we can tuck the rarely used `PrintMenu` under `I/O`)

Add list product, sum, etc to `ListMenu`

Modify `ProgramMenu` to add special program entry characters.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-28 23:51:08 +01:00
Christophe de Dinechin
765a97c6e7 lists: Separate list sum/product from regular sum/product
For some reason, I used the `Sum` (`Σ`) and `Product` (`∏`) commands
for list sums and products. This is not the way the HP48/HP50 do it,
so it's better to have dedicated `ΣList` and `∏List` commands.

Also implemented the missing `∆List` command and added the missing
related tests for all these commands.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-28 23:51:08 +01:00
Christophe de Dinechin
5362dd634c graph: Improve rendering of exp, exp2, exp10
Use a smaller font for the argument of these functions.

Also add tests for `sqrt`, `cbrt` and `xroot`

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-28 23:51:08 +01:00
Christophe de Dinechin
fbae01c5f8 graph: Add graphical rendering for cbrt (cube root)
Make it look like the regular root.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-27 17:48:48 +01:00
Christophe de Dinechin
67871dd95f graph: Graphical rendering of xroot
Render xroot graphically in expressions.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-27 17:48:48 +01:00
Christophe de Dinechin
4db8bd0b2e expressions: Add code for n-ary functions
Add code that deals with n-ary expressions, such as `comb`, `perm` or
`xroot`.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-26 23:23:44 +01:00
Christophe de Dinechin
a2ce949b23 functions: Add combinations and permutations
Add combination and permutation functions, as well as tests for
probabilities.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-26 20:22:01 +01:00
Christophe de Dinechin
c4db7c3a44
Merge pull request #856 from kjellc/fix-simulator-missing-fast-mouse-clicks
Fixed problem in simulator missing quick mouse clicks
2024-03-25 19:03:28 +01:00
Christophe de Dinechin
22b2546336
Merge pull request #858 from vkadlcik/stable
Add a missing build dependency on Fedora
2024-03-25 19:00:26 +01:00
Christophe de Dinechin
2240b6edfa Release 0.7.3 "Perfume" - Mostly bug fixes
This release is mostly about bug fixes, improving the build on
simulator, and accelerating the test suite while keeping it stable.

** New features **

* simulator: Add F8 key to save state in the simulator
* errors: Add a beep when an error is shown
* linux: Add `-s` option for screen scaling (when Qt gets scaling wrong)
* equations: Get library equation value for plotter, solver and integrator
* characters: Add constant, equation and lib markers to RPL menu
* characters: Add music-related characters and character menu
* commands: Add missing stack commands (nip, pick3, ndupn, unrot, unpick)

** Bug fixes **

* variables: Clone purged objects on stack after `Purge`
* units: unit * symbolic is preserved as is (e.g. `'A'_m`)
* compare: Enforce the `NumericalResults` flag for comparisons
* constants: Fix parsing of constants, equations and library items
* sto: Repair `file exists` error storing to a source file
* simulator: Do not try to create directory if it exists
* Report file errors, e.g. permissions or I/O errors
* equations: Mark `c` and `R` as constants in equations
* simulator: Double clicks are now considered as virtual keyboard touches
* ui: Emit only one beep, not two, for a syntax error on the command line
* ui: Avoid rare null-dereference crash when menu label is not set
* complex: Report a syntax error if the second half is empty
* utf8: Do not accept constant/equation/library codepoint in names
* units: Multiplying by `1_m` is OK even with algebraic
* tests: Avoid case where CLEAR does not clear errors
* audio: Improve audio reliability on the simulator
* linux: Rewrite the audio-generation code to avoid crashes
* linux: Avoid infinite recursion in the tests
* linux: Fix warnings about unused variables
* linux: Avoid warnings about null pointer in strcmp
* linux: Avoid build error due to bad `ularge` overload in settings
* linux: Fix type issue for the Insert function (reported as a warning)
* linux: Remove warning about mixing enums and integers
* linux: Avoid error on printf format
* linux: Avoid warnings about type qualifiers
* linux: Remove warnings about incompatible function casts
* linux: Address warnings about missing initializers
* linux: Fix warning about prinf formats
* linux: Address warning about signed vs unsigned
* linux: Remove warning about fall-through switch statement
* linux: Remove warnings about unused arguments
* tests: Repair several tests that were unstable due to scrolling images
* tests: Increase memory size to avoid occasional out of memory failures
* object: Make `as_uint32` and `as_uint64` consistent for negative input

** Improvements **

* ui: Emulate HP48/HP50G behavior for errors (do not require key to continue)
* simulator: Add I/O wrapper around file state save/restore
* dmcp: Remove double return in the code
* simulator: Accept numeric keys in DMCP menus
* doc: Add Kjell Christenson to list of authors
* tests: Run command-line tests silently
* tests: Clear settings the fast way for quick tests
* dmcp: Do not treat the buzzer as a recorder error (avoid message noise)
* simulator: Ensure error messages show up in a recorder dump
* tests: Increase memory size to avoid failing tests
* tests: Increase delay waiting for function plots to appear
* tests: Refactor test suite interaction with RPL thread to accelerate it
* tests: Add a delay before launching the test thread to load initial state
* tests: Add missing reference picture for `char-menu`

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-25 00:48:37 +01:00
Christophe de Dinechin
e77b00945e stack-cmds: Add missing stack commands
Add the `unpick`, `unrot` and `ndupn` commands along with tests.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-25 00:44:52 +01:00
Christophe de Dinechin
688599ea57 object: Make as_uint32 and as_uint64 consistent for negative input
The `as_uint32()` and `as_uint64()` functions were not consistent for
all kinds of negative input. Make them return default value or
`value_error()` in all cases.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-25 00:30:57 +01:00
Christophe de Dinechin
cee7fa003f stack-cmds: Add pick3 command
Add the `pick3` command, not connected in the menu yet.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-25 00:30:57 +01:00
Christophe de Dinechin
d535c237f1 stack-cmd: Save LastArg for stack operations
The `LastArg` stack was not correctly saved for the stack operations.
Note that the behaviour of these commands is not always very
consistent across commands. Some attempts were made to replicate the
HP behaviour for commands like `Pick` or `DropN` for compatibility.

Fixes: #859

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-25 00:30:57 +01:00
Christophe de Dinechin
d3930883a8 stack-cmds: Add nip command
The `nip` command is equivalent to `swap drop`
It's an HP-50G only command.

Fixes: #841

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-25 00:30:57 +01:00
Václav Kadlčík
0fd951cb98 Add a missing build dependency on Fedora 2024-03-24 19:49:59 +01:00
Christophe de Dinechin
73df1fe726 tests: Remove explicit .wait() and WAIT() calls
With the new test/RPL sync, we no longer need the explicit waits.

With this, we regularly go below 300s for the whole test suite.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:55 +01:00
Christophe de Dinechin
dcfe05cb4c ui: Avoid rare crash case in user_interface::label
It is possible for that function to be called when there is no label.
In that case, we do a null-dereference trying to check if we have a
symbol instead of a text.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:55 +01:00
Christophe de Dinechin
6df12cd583 characters: Add music characters menu
The `Boxes` menu is a replication of the `Blocks` menu.
Replace it with a `Music` menu.

Add four missing music glyphs to the font.

Also add the reference file for `chars-menu.png`, which was missing.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:55 +01:00
Christophe de Dinechin
e22b9aced1 tests: Change default test key time to 1ms.
This executes the test suite in 268s instead of 552s.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:55 +01:00
Christophe de Dinechin
10f8135a3c tests: Adjust image for constants
We are now displaying constants in bold

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:55 +01:00
Christophe de Dinechin
fca3af62bb tests: Adjust RPL character menu output
The output now includes markers for constants, equations, etc.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:55 +01:00
Christophe de Dinechin
03d5211fb4 tests: Adjust plot tests to new test infrastructure
Add a check for `LastArgs` returning the last equation and not the
last evaluation argument for the plot function.
This fixes the problem with `plot-pgm` mismatch.

Also replace explicit wait times with uses of `LENGTHY`.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:55 +01:00
Christophe de Dinechin
30fdb68279 tests: Additional key processing in Wait and Show commands
The new sync between tests and RPL theads was not working correctly in
the case of `Wait` and `Show` commands because they were popping keys
without correctly updating `last_key`.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:55 +01:00
Christophe de Dinechin
7ccea31843 tests: Fix mismatch on help-exit.png and help-keyboard.png
The `Lib` menu was added, which changes the default screen. This
explains the observed change in `help-exit.png`.

There was a minor change in clipping for the help that causes a
mismatch on `help-keyboard.png`.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-24 15:30:54 +01:00
Christophe de Dinechin
b7920c0e9a tests: Add a mechanism for running long tests without waiting
Instead of actively waiting, increase the maximum default wait time
for the duration of the test. This makes it possible to run the
function plotting tests much faster, while not failing on the slower
ones like `gamma` and `lgamma`.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 23:07:27 +01:00
Christophe de Dinechin
3bdafe49b5 tests: Increase memory size to avoid failing tests
Some tests fail running out of memory:

```
../src/tests.cc:2669:  Test #21: highp: High-precision computations (60 digits)
../src/tests.cc:2669:  21:045.001: cbrt
../src/tests.cc:2669:    Expected output [0.68470 21277 57224 16184 09277 32646 81496 28057 14749 53139 45950 35873 52977 73009 35191 71304 84396 28932 73625 07589 02266 77954 73690 2353], got error [Out of memory] instead
```

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
fb016958cd tests: Increase delay waiting for function plots to appear
When running tests, the image check files for function plots often
fail due to the plot not having completed.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
a7f9fd4cab tests: Another refactoring of the test interface with RPL thread
Split the recorders between `tests` and `tests_rpl`.
Separate the handling of commands into `process_test_commands` and
`process_test_key`, with the key handling happening before we actually
run the code.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
9ea262a0a5 tests: Adjust check for key
Some keys, like `ENTER` or immediate keys, can be processed before we
get the key release. In that case, the release is actually consumed by
`program::interrupted` and not by the main runner thread, so that we
cannot rely on that to get the correct output key.
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
629494fd0e tests: Cache information while reading the stack
When reading the stack, cache what is being read so that we have a
consistent set of values.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
189abcf40c tests: Timing information
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
88207e7eff simulator: Accelerate sys_sleep when running tests
This significantly improves the performance of tests by avoiding
delays waiting to process keys.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
1f6f148634 tests: Reorganize synchronization between RPL thread and tests
Use a separate channel for the communication of test commands with
the RPL thread, in order to make it simpler to deal with corner cases
such as an error being displayed.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
cc31dcf470 switch from rt.clear_error to clear_error
Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:15 +01:00
Christophe de Dinechin
1e71991af2 tests: Add a delay before launching the test thread
This delay is necessary to avoid an occasional crash at startup when
running with `-Tall` and loading a large demo file.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:14 +01:00
Christophe de Dinechin
e6629200d9 tests: Pass the extrawait argument to nokeys() inside source()
Just for consistency, better to pass the arguments around

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:14 +01:00
Christophe de Dinechin
3aca2e871b simulator: Cache key value in stack instrumentation
Just make sure that we read the value only once, as it's possibly
written by another thread, so it's better to have a single value in
the instrumentation.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:14 +01:00
Christophe de Dinechin
fcea67bdd6 tests: Split key sync code as a separate function
Preparatory work to be able to also use that keysync code when dealing
with errors.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:14 +01:00
Christophe de Dinechin
4aab88627a tests: Drop dead code for stackdepth 0
When recording the stack for the test suite, there is a sspecial case
for a depth of 0 that is dead code (we return earlier in that case)
and is actually not supported by the test suite if activated.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:23:14 +01:00
Christophe de Dinechin
b959db1e27 tests: Add a commonly failing test to current test
The error handling in the tests is now often failing due to the fact
that we no longer need to hit a BSP / ENTER key to clear it.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-23 10:21:50 +01:00
Christophe de Dinechin
60306ef4e7 For recorder in errors, show errors with %+s
All error messages are static strings, so safe to display in the
recorder.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Christophe de Dinechin
e24546b87a simulator: Add I/O wrapper
Put some common code for saving and restoring files in a wrapper.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Christophe de Dinechin
8f2fc58497 simulator: Add interface to report file errors
When writing to a file and there is an error, make sure we see it.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Christophe de Dinechin
b1c9856611 simulator: Add F8 key to save state in the simulator
This is a shortcut to save the current state.
Note that you can also get that with RSHIFT-EXIT.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00
Christophe de Dinechin
79760be3e4 dmcp: Avoid double return in the code
Two returns one after another are one too many.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
2024-03-22 14:34:43 +01:00