mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 17:37:09 +01:00
1400b5e218
* fix(editor): track edits keep the joints, the norms, the records and the saved speed together - The cant typed in the inspector goes on into the track joined at that end, as the gizmo and the joints tool do it; the neighbours go into the same undo step. The joint stepped before. - A track laid on from a canted joint takes the cant off along the ramp the norms ask for at the speed (`alignment::cant_ramp_length`), not at a fixed 1.5 mm a metre whatever the speed and the norms: 120 mm at 100 km/h over 120 m, not 80 m. - Deleting a track of the line under the route tool keeps the laying norms. They went back to the defaults, and every later lay, extend and join used those. - The gauge is a paste group of its own, off by default: pasting how a track rides or sounds no longer changes its gauge. - The speed of a turntable set in the editor is the one saved. The editor changed the speed the turntable runs at, while the file keeps the limit it was loaded with. - Deleting a set of tracks does what Del does with each: a double switch, a slip and a crossover go whole, the records of the switches go with them, and the model and events of a turntable too. The records stayed behind and on saving were given to another switch, which then showed a wrong type. - Deleting a switch of a crossover takes the crossover out whole, as the connection tools do: the outer track of a crossover on a curve comes down by its lift and the record of the connection goes. Alone, the switch left the outer track up for good, and the connection to the next switch given its name. A switch bent out of the shape of its record is found by its name. Tests: a unit test of the norm ramp. The other changes are in the editor's UI, which the unit tests don't reach. * test(editor): self-test scripts that fail, a runner, and a case for each fix of the track editing The editor's self-test scripts only logged: nothing made a run fail. Now: - `expect` commands check the state and log `SELFTEST PASS` or `SELFTEST FAIL ... got X, expected Y`: the cant at a track end, the joint at an end (gap, angle, cant step), the records of a switch and the connections naming it, speed, gauge, a track present or removed, the laying norms' gauge, heights and lifts against a mark, whether a track is in the line under the route tool, and the includes of a turntable. A command no group takes counts as a failure, so a mistyped one can't make the checks after it pass. - At `quit` the result is logged, and a script whose expectations failed ends the editor with exit code 2 (a failed start stays 1; the simulator's test mode is unchanged). - The commit of the inspector's cant field is `track_cant_commit`, which the inspector and the `trackcant` command both call; `routegauge` sets the laying norms as the route tool does, and `tracksetdelete` deletes a set of tracks by name. - `tests/editor/run.py` runs each script of `tests/editor/cases` on a copy of the fixture scenery in the game folder, with a wall-time limit and a memory cap, reads the exit code and the `SELFTEST` lines, and deletes the copy. A `#> reopen` line restarts the editor on the saved scenery. See `tests/editor/README.md`. - One case per fix of the track editing quick fixes (inspector cant, norms after deleting, the gauge paste group, turntable speed saved, deleting a set, a set with a double switch, a slip and a crossover, deleting a switch of a crossover, a bent switch). All pass; with the fixes reverted all fail. * test(editor): a mistyped track fails the self-test, indented comments are skipped, case 7b checks the switch got bent - A blank line or an indented `#` comment in a script is no longer a command no group takes. - `trackcant`, `routegauge` and `tracksetdelete` with a track that isn't there count as a failed expectation. - `expect shaped <switch> <yes|no>`: 7b checks that the gizmo drag bent the switch out of its record before deleting it. - The ramp-length loop of test_alignment counts in an integer (Sonar S2193).
71 lines
1.6 KiB
C++
71 lines
1.6 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <algorithm>
|
|
#include <cstddef>
|
|
#include <string>
|
|
|
|
// what the groups of the self-test commands share, each group in a file of its own
|
|
namespace editor_selftest
|
|
{
|
|
|
|
// frames gone through the selftest, for the measurements of perf
|
|
inline std::size_t &frames()
|
|
{
|
|
static std::size_t count{0};
|
|
return count;
|
|
}
|
|
|
|
// the longest frame since the last perf, and the frames longer than 33 ms
|
|
inline double &frame_longest()
|
|
{
|
|
static double value{0.0};
|
|
return value;
|
|
}
|
|
|
|
inline std::size_t &frames_slow()
|
|
{
|
|
static std::size_t count{0};
|
|
return count;
|
|
}
|
|
|
|
// the expectations of the script checked, and those of them which failed, with the commands no group knew. At quit the run ends
|
|
// with failed_exit_code when any failed, for the runner of the scripts (tests/editor/run.py)
|
|
inline std::size_t &expectations()
|
|
{
|
|
static std::size_t count{0};
|
|
return count;
|
|
}
|
|
|
|
inline std::size_t &failures()
|
|
{
|
|
static std::size_t count{0};
|
|
return count;
|
|
}
|
|
|
|
// a command whose subject isn't there, a track name mistyped, fails the run as an expectation does
|
|
inline void fail()
|
|
{
|
|
++expectations();
|
|
++failures();
|
|
}
|
|
|
|
// apart from the 1 of a start which failed or of an error which ended the editor
|
|
inline constexpr int failed_exit_code{2};
|
|
|
|
inline std::string one_line(std::string Text)
|
|
{
|
|
std::replace(Text.begin(), Text.end(), '\n', ';');
|
|
return Text;
|
|
}
|
|
|
|
} // namespace editor_selftest
|