<commit_before>"use strict";

const assert = require("assert");
const path = require("path");
const fs = require("fs");
const recast = require("../main.js");
const parse = require("../lib/parser").parse;
const Printer = require("../lib/printer").Printer;
const types = require("../lib/types");
const eol = require("os").EOL;
const babylon = require("babylon");
const babylonOptions = {
  sourceType: "module",
  plugins: [
    'typescript',
    'classProperties',
    'asyncGenerators',
    'decorators',
    'objectRestSpread',
  ]
};

const parser = {
  parse(source) {
    return babylon.parse(source, babylonOptions);
  }
};

describe("TypeScript", function() {
  it('basic printing', function() {
    function check(lines) {
      const code = lines.join(eol);
      const ast = recast.parse(code, { parser });
      const output = recast.prettyPrint(ast, { tabWidth: 2 }).code;
      assert.strictEqual(code, output);
    }

    check([
      'let color: string = "blue";',
      'let isDone: boolean = false;',
      'let decimal: number = 6;',
      'let hex: number = 0xf00d;',
      'let binary: number = 0b1010;',
      'let octal: number = 0o744;',
      'let list: number[] = [1, 2, 3];',
      'let matrix: number[][];',
      'let x: [string, number];',
      'let f: <E>(e: E) => void;',
      'let sn: string | null = "isNull";'
    ]);

    check([
      'type A = number;',
      'type B = string;',
      'type C = never;',
      'type D = any;',
      'type E = [string, number];',
      'type F = void;',<commit_msg>Update test/typescript.js to use reify/parsers/typescript.<commit_after>"use strict";

const assert = require("assert");
const path = require("path");
const fs = require("fs");
const recast = require("../main.js");
const parse = require("../lib/parser").parse;
const Printer = require("../lib/printer").Printer;
const types = require("../lib/types");
const eol = require("os").EOL;
const parser = require("../parsers/typescript");

describe("TypeScript", function() {
  it('basic printing', function() {
    function check(lines) {
      const code = lines.join(eol);
      const ast = recast.parse(code, { parser });
      const output = recast.prettyPrint(ast, { tabWidth: 2 }).code;
      assert.strictEqual(code, output);
    }

    check([
      'let color: string = "blue";',
      'let isDone: boolean = false;',
      'let decimal: number = 6;',
      'let hex: number = 0xf00d;',
      'let binary: number = 0b1010;',
      'let octal: number = 0o744;',
      'let list: number[] = [1, 2, 3];',
      'let matrix: number[][];',
      'let x: [string, number];',
      'let f: <E>(e: E) => void;',
      'let sn: string | null = "isNull";'
    ]);

    check([
      'type A = number;',
      'type B = string;',
      'type C = never;',
      'type D = any;',
      'type E = [string, number];',
      'type F = void;',
{'fraction_non_alphanumeric': 0.19260293091416608, 'fraction_numerical': 0.011863224005582694, 'mean_word_length': 2.895380434782609, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '3555953', 'n_tokens_mistral': 975, 'n_tokens_neox': 945, 'n_words': 257}