<commit_before>import * as empty from "./empty.wast";
import * as constant from "./constant.wast";
import * as square from "./square.wast";
import * as controlflow from "./controlflow.wast";
import * as counter from "./counter.wast";

declare const WebAssembly: any;

function instantiate(bytes, imports) {
    const bytes8 = Uint8Array.from(bytes);
    return WebAssembly.compile(bytes8).then(m => new WebAssembly.Instance(m, imports));
}

describe("empty", () => {
    it("does not blow up", (done) => {
        instantiate(empty, {}).then(() => {
            done();
        });
    });
});

describe("constant", () => {
    it("returns the constant 42", (done) => {
        instantiate(constant, {}).then(instance => {
            expect(instance.exports.answer).toBe(42);
            done();
        });
    });
});

describe("square", () => {
    it("squares the input number", (done) => {
        instantiate(square, {}).then(instance => {
            expect(instance.exports.square(2)).toBe(4);
            expect(instance.exports.square(3)).toBe(9);
            expect(instance.exports.square(4)).toBe(16);
            done();
        });
    });
});

describe("square with alternative syntax", () => {
    it("squares the input number", (done) => {
        instantiate(square, {}).then(instance => {
            expect(instance.exports.square_alt_syntax(2)).toBe(4);
            expect(instance.exports.square_alt_syntax(3)).toBe(9);
            expect(instance.exports.square_alt_syntax(4)).toBe(16);<commit_msg>chore: add expectation to empty()<commit_after>import * as empty from "./empty.wast";
import * as constant from "./constant.wast";
import * as square from "./square.wast";
import * as controlflow from "./controlflow.wast";
import * as counter from "./counter.wast";

declare const WebAssembly: any;

function instantiate(bytes, imports) {
    const bytes8 = Uint8Array.from(bytes);
    return WebAssembly.compile(bytes8).then(m => new WebAssembly.Instance(m, imports));
}

describe("empty", () => {
    it("does not blow up", (done) => {
        instantiate(empty, {}).then((instance) => {
            expect(instance).not.toBeNull();
            done();
        });
    });
});

describe("constant", () => {
    it("returns the constant 42", (done) => {
        instantiate(constant, {}).then(instance => {
            expect(instance.exports.answer).toBe(42);
            done();
        });
    });
});

describe("square", () => {
    it("squares the input number", (done) => {
        instantiate(square, {}).then(instance => {
            expect(instance.exports.square(2)).toBe(4);
            expect(instance.exports.square(3)).toBe(9);
            expect(instance.exports.square(4)).toBe(16);
            done();
        });
    });
});

describe("square with alternative syntax", () => {
    it("squares the input number", (done) => {
        instantiate(square, {}).then(instance => {
            expect(instance.exports.square_alt_syntax(2)).toBe(4);
            expect(instance.exports.square_alt_syntax(3)).toBe(9);
            expect(instance.exports.square_alt_syntax(4)).toBe(16);
{'fraction_non_alphanumeric': 0.18339211285668483, 'fraction_numerical': 0.01346585444052581, 'mean_word_length': 2.8805970149253732, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6563375', 'n_tokens_mistral': 943, 'n_tokens_neox': 902, 'n_words': 174}