Files
001code-html--cocos/scratch-vm/test/unit/blocks_pen_tw.js
刘宇飞 6e0a1fbcbb Initial commit of 001code-html Scratch frontend project.
Includes scratch-gui, scratch-vm, scratch-blocks, scratch-render, scratch-l10n, and deployment config.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-16 15:37:45 +08:00

33 lines
1009 B
JavaScript

const test = require('tap').test;
const Runtime = require('../../src/engine/runtime');
const Scratch3PenBlocks = require('../../src/extensions/scratch3_pen/index');
test('_clampPenSize', t => {
const rt = new Runtime();
const pen = new Scratch3PenBlocks(rt);
t.equal(pen._clampPenSize(-1), 1);
t.equal(pen._clampPenSize(0), 1);
t.equal(pen._clampPenSize(0.25), 1);
t.equal(pen._clampPenSize(1), 1);
t.equal(pen._clampPenSize(10), 10);
t.equal(pen._clampPenSize(1000), 1000);
t.equal(pen._clampPenSize(1200), 1200);
t.equal(pen._clampPenSize(1201), 1200);
rt.setRuntimeOptions({
miscLimits: false
});
t.equal(pen._clampPenSize(-1), 0);
t.equal(pen._clampPenSize(0), 0);
t.equal(pen._clampPenSize(0.25), 0.25);
t.equal(pen._clampPenSize(1), 1);
t.equal(pen._clampPenSize(10), 10);
t.equal(pen._clampPenSize(1000), 1000);
t.equal(pen._clampPenSize(1200), 1200);
t.equal(pen._clampPenSize(1201), 1201);
t.end();
});