UNPKG

@casual-simulation/aux-common

Version:
182 lines 5.58 kB
/* CasualOS is a set of web-based tools designed to facilitate the creation of real-time, multi-user, context-aware interactive experiences. * * Copyright (c) 2019-2025 Casual Simulation, Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ import { Vector2, Vector3 } from '../../math'; import { Rotation } from '../../math/Rotation'; import { DNA_TAG_PREFIX } from '../Bot'; import { formatBotRotation } from '../BotCalculations'; export const possibleTagNameCases = [ ['""', ''], ['0', '0'], ['"a"', 'a'], ['1', '1'], ['-10', '-10'], ['"1"', '1'], ['".5"', '.5'], ['.5', '0.5'], ['false', 'false'], ['"false"', 'false'], ['true', 'true'], ['"true"', 'true'], ]; export const possibleTagValueCases = [ ['', ''], [null, null], [0, 0], [`${DNA_TAG_PREFIX}false`, false], [`${DNA_TAG_PREFIX}0`, 0], ['a', 'a'], [1, 1], [-10, -10], ['1', 1], ['.5', 0.5], [false, false], ['false', false], [true, true], ['true', true], [`${DNA_TAG_PREFIX}1`, 1], [`${DNA_TAG_PREFIX}"hello"`, 'hello'], ]; export function booleanTagValueTests(defaultValue, testFunc) { let cases = [ ['', defaultValue], [null, defaultValue], [undefined, defaultValue], [0, defaultValue], ['=false', defaultValue], ['=0', defaultValue], ['a', defaultValue], [1, defaultValue], [false, false], ['false', false], [true, true], ['true', true], [new Boolean(true), true], [new Boolean(false), false], ['=1', defaultValue], ['="hello"', defaultValue], ]; it.each(cases)('should map %s to %s', testFunc); } export function numericalTagValueTests(defaultValue, testFunc) { let cases = [ ['', defaultValue], [null, defaultValue], [undefined, defaultValue], [0, 0], ['=false', defaultValue], ['=0', defaultValue], ['a', defaultValue], [1, 1], [-10, -10], ['1', 1], ['.5', 0.5], [false, defaultValue], ['false', defaultValue], [true, defaultValue], ['true', defaultValue], ['=1', defaultValue], ['="hello"', defaultValue], ]; it.each(cases)('should map %s to %s', testFunc); } export function stringTagValueTests(defaultValue, testFunc) { let cases = [ ['', ''], [null, defaultValue], [undefined, defaultValue], [0, defaultValue], ['=false', '=false'], ['=0', '=0'], ['a', 'a'], [1, defaultValue], ['1', defaultValue], ['.5', defaultValue], [false, defaultValue], ['false', defaultValue], [true, defaultValue], ['true', defaultValue], ['=1', '=1'], ['="hello"', '="hello"'], ]; it.each(cases)('should map %s to %s', testFunc); } export function vectorTagValueTests(defaultValue, testFunc) { let cases = [ ['', defaultValue], [null, defaultValue], [undefined, defaultValue], [0, defaultValue], ['=false', defaultValue], ['=0', defaultValue], ['a', defaultValue], [1, defaultValue], [-10, defaultValue], ['1', defaultValue], ['.5', defaultValue], [false, defaultValue], ['false', defaultValue], [true, defaultValue], ['true', defaultValue], ['=1', defaultValue], ['="hello"', defaultValue], ['➡️', defaultValue], ['➡️1', defaultValue], ['➡️1,2', new Vector2(1, 2)], ['➡️1,2,3', new Vector3(1, 2, 3)], ]; it.each(cases)('should map %s to %s', testFunc); } export function rotationTagValueTests(defaultValue, testFunc) { let cases = [ ['', defaultValue], [null, defaultValue], [undefined, defaultValue], [0, defaultValue], ['=false', defaultValue], ['=0', defaultValue], ['a', defaultValue], [1, defaultValue], [-10, defaultValue], ['1', defaultValue], ['.5', defaultValue], [false, defaultValue], ['false', defaultValue], [true, defaultValue], ['true', defaultValue], ['=1', defaultValue], ['="hello"', defaultValue], ['➡️', defaultValue], ['➡️1', defaultValue], ['➡️1,2', defaultValue], ['➡️1,2,3', defaultValue], ['🔁0,0,0', defaultValue], ['🔁0,0,0,1', new Rotation()], [ formatBotRotation(new Rotation({ axis: new Vector3(0, 1, 0), angle: Math.PI / 2, })), new Rotation({ axis: new Vector3(0, 1, 0), angle: Math.PI / 2, }), ], ]; it.each(cases)('should map %s to %s', testFunc); } //# sourceMappingURL=BotTestHelpers.js.map