<commit_before>﻿import * as assert from "assert";
import CodeBlockWriter from "code-block-writer";
import {FileDefinition} from "./../../definitions";
import {getStringInfo} from "./../../main";
import {FileWriter} from "./../../writers";

function getFileAsString(f: FileDefinition) {
    const codeBlockWriter = new CodeBlockWriter();
    const writer = new FileWriter(codeBlockWriter);

    writer.write(f);

    return codeBlockWriter.toString();
}

describe("Ambientable", () => {
    const code = `
declare namespace MyNamespace {
}
declare module MyModule {
}
declare namespace MyOtherNamespace {
    function myOtherFunction(): void;
}
declare interface MyInterface {
}
declare class MyClass {
}
declare enum MyEnum {
}
declare function myFunction(): void;
`;
    const myFile = getStringInfo(code);

    describe("write()", () => {
        it("should contain the file written out with declare keywords", () => {
            const expected =
`declare namespace MyNamespace {
}

declare module MyModule {
}

declare namespace MyOtherNamespace {
    function myOtherFunction(): void;
}

declare interface MyInterface {
}

declare class MyClass {
}

declare enum MyEnum {
}

declare function myFunction(): void;
`;
            assert.equal(getFileAsString(myFile), expected);
        });
    });
});
<commit_msg>Code coverage improvement for definition-utils<commit_after>﻿import * as assert from "assert";
import CodeBlockWriter from "code-block-writer";
import {FileDefinition} from "./../../definitions";
import {getStringInfo} from "./../../main";
import {FileWriter} from "./../../writers";

function getFileAsString(f: FileDefinition) {
    const codeBlockWriter = new CodeBlockWriter();
    const writer = new FileWriter(codeBlockWriter);

    writer.write(f);

    return codeBlockWriter.toString();
}

describe("Ambientable", () => {
    const code = `
declare namespace MyNamespace {
}
declare module MyModule {
}
declare namespace MyOtherNamespace {
    interface myOtherInterface {}
    function myOtherFunction(): void;
}
declare interface MyInterface {
}
declare class MyClass {
}
declare enum MyEnum {
}
declare function myFunction(): void;
`;
    const myFile = getStringInfo(code);

    describe("write()", () => {
        it("should contain the file written out with declare keywords", () => {
            const expected =
`declare namespace MyNamespace {
}

declare module MyModule {
}

declare namespace MyOtherNamespace {
    interface myOtherInterface {
    }

    function myOtherFunction(): void;
}

declare interface MyInterface {
}

declare class MyClass {
}

declare enum MyEnum {
}

declare function myFunction(): void;
`;
            assert.equal(getFileAsString(myFile), expected);
        });
    });
});

{'fraction_non_alphanumeric': 0.12586647209047794, 'fraction_numerical': 0.0, 'mean_word_length': 3.8105263157894735, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2963504', 'n_tokens_mistral': 771, 'n_tokens_neox': 729, 'n_words': 218}