microvium
Version:
A compact, embeddable scripting engine for microcontrollers for executing small scripts written in a subset of JavaScript.
92 lines • 4.93 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
const common_1 = require("../common");
const filenames_1 = require("./filenames");
const binary_region_1 = require("../../lib/binary-region");
const general_1 = require("../../lib/general");
const formats = __importStar(require("../../lib/snapshot-binary-html-formats"));
suite(binary_region_1.BinaryRegion.name, function () {
test('empty', () => {
const testResults = new common_1.TestResults();
const region = new binary_region_1.BinaryRegion();
const outputBinary = region.toBuffer();
const outputHTML = (0, general_1.htmlPageTemplate)(region.toHTML());
testResults.push(outputBinary, filenames_1.binaryRegionFilenames.empty.binary);
testResults.push(outputHTML, filenames_1.binaryRegionFilenames.empty.html);
testResults.checkAll();
});
test('basic', () => {
const testResults = new common_1.TestResults();
const region = new binary_region_1.BinaryRegion();
region.append(1, undefined, formats.uInt8Row);
region.append(2, undefined, formats.sInt8Row);
region.append(-2, undefined, formats.sInt8Row);
region.append(3, undefined, formats.uInt16LERow);
region.append(3, undefined, formats.sInt16LERow);
region.append(-3, undefined, formats.sInt16LERow);
region.append(4, undefined, formats.uInt32LERow);
region.append(4, undefined, formats.sInt32LERow);
region.append(-4, undefined, formats.sInt32LERow);
region.append(5, undefined, formats.doubleLERow);
region.append(0.5, undefined, formats.doubleLERow);
region.append(-0.5, undefined, formats.doubleLERow);
region.append('Hello, World!', undefined, formats.stringUtf8NTRow);
const outputBinary = region.toBuffer();
const outputHTML = (0, general_1.htmlPageTemplate)(region.toHTML());
testResults.push(outputBinary, filenames_1.binaryRegionFilenames.basic.binary);
testResults.push(outputHTML, filenames_1.binaryRegionFilenames.basic.html);
testResults.checkAll();
});
test('placeholders', () => {
const testResults = new common_1.TestResults();
const region = new binary_region_1.BinaryRegion();
const futurePrefilled = new binary_region_1.Future();
const futurePostFilled = new binary_region_1.Future();
const futureUnfilled = new binary_region_1.Future();
futurePrefilled.assign(41);
region.append(1, undefined, formats.uInt8Row);
region.append(2, undefined, formats.sInt8Row);
region.append(-2, undefined, formats.sInt8Row);
region.append(3, undefined, formats.uInt16LERow);
region.append(futurePrefilled, undefined, formats.sInt16LERow);
region.append(futurePostFilled, undefined, formats.sInt16LERow);
region.append(futureUnfilled, undefined, formats.sInt16LERow);
region.append(4, undefined, formats.uInt32LERow);
region.append(4, undefined, formats.sInt32LERow);
region.append(-4, undefined, formats.sInt32LERow);
region.append(5, undefined, formats.doubleLERow);
region.append(0.5, undefined, formats.doubleLERow);
region.append(-0.5, undefined, formats.doubleLERow);
region.append('Hello, World!', undefined, formats.stringUtf8NTRow);
futurePostFilled.assign(42);
const outputBinary = region.toBuffer(false);
const outputHTML = (0, general_1.htmlPageTemplate)(region.toHTML());
testResults.push(outputBinary, filenames_1.binaryRegionFilenames.placeholders.binary);
testResults.push(outputHTML, filenames_1.binaryRegionFilenames.placeholders.html);
testResults.checkAll();
});
});
//# sourceMappingURL=binary-region.test.js.map