mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-07-10 04:54:04 -04:00
feat: Allow switching to specially named backdrops
The `switch costume` block accepts special values like "next costume" and "previous costume". If you create a costume with these names, these take priority over the special values. However, the `switch backdrop` block keeps these special values for values like "next backdrop", "previous backdrop", "random backdrop". It is impossible to navigate to such a backdrop by name via block. This commit also modifies tests to allow for this. BREAKING CHANGE: specially-named backdrops can now be navigated
This commit is contained in:
parent
0c18b4952d
commit
341bd8f3d3
2 changed files with 11 additions and 8 deletions
test/unit
|
@ -129,9 +129,11 @@ test('switch backdrop block runs correctly', t => {
|
|||
t.strictEqual(testBackdrop(['a', 'b', 'c', 'd'], 'previous backdrop', 3), 2);
|
||||
t.strictEqual(testBackdrop(['a', 'b', 'c', 'd'], 'next backdrop', 2), 3);
|
||||
|
||||
// 'previous backdrop' and 'next backdrop' can't be overriden
|
||||
t.strictEqual(testBackdrop(['a', 'previous backdrop', 'c', 'd'], 'previous backdrop', 4), 3);
|
||||
t.strictEqual(testBackdrop(['next backdrop', 'b', 'c', 'd'], 'next backdrop'), 2);
|
||||
// 'previous backdrop', 'previous backdrop', 'random backdrop' can be overriden
|
||||
// Test is deterministic since 'random backdrop' will not pick the same backdrop as currently selected
|
||||
t.strictEqual(testBackdrop(['a', 'previous backdrop', 'c', 'd'], 'previous backdrop', 4), 2);
|
||||
t.strictEqual(testBackdrop(['next backdrop', 'b', 'c', 'd'], 'next backdrop', 3), 1);
|
||||
t.strictEqual(testBackdrop(['random backdrop', 'b', 'c', 'd'], 'random backdrop'), 1);
|
||||
|
||||
// NaN, Infinity, and true are the first costume
|
||||
t.strictEqual(testBackdrop(['a', 'b', 'c', 'd'], NaN, 2), 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue