From 942d22dd7013daa9a0d4489c65019f29f4a0a787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Sat, 19 Aug 2017 18:25:18 +0200 Subject: [PATCH] Remove the `get_harcoded_tests` function, use `get_tests` --- scripts/run_flow_tests.js | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/scripts/run_flow_tests.js b/scripts/run_flow_tests.js index a88d20aa85..f74df55c62 100644 --- a/scripts/run_flow_tests.js +++ b/scripts/run_flow_tests.js @@ -5,6 +5,8 @@ const fs = require("fs"); const chalk = require("chalk"); const parse = require("..").parse; +const TESTS_FOLDER = path.join(__dirname, "../build/flow/src/parser/test/flow"); + function map_get_default(map, key, defaultConstructor) { if (map.has(key)) { return map.get(key); @@ -65,18 +67,6 @@ function get_tests(root_dir) { return tests; } -function get_hardcoded_tests() { - const tests = get_tests( - path.join(__dirname, "../build/flow/src/parser/test/flow") - ); - const result = new Map(); - tests.forEach((section, sectionName) => { - const cases = Array.from(section.values()); - result.set(sectionName, { tests: cases }); - }); - return result; -} - const options = { plugins: ["jsx", "flow", "asyncGenerators", "objectRestSpread"], sourceType: "module", @@ -92,11 +82,11 @@ const flowOptionsMapping = { let failedTests = 0; let successTests = 0; -const tests = get_hardcoded_tests(); +const tests = get_tests(TESTS_FOLDER); tests.forEach((section, sectionName) => { console.log(""); console.log(`### ${sectionName} ###`); - section.tests.forEach(test => { + section.forEach(test => { const shouldSuccess = test.expected_ast && (!Array.isArray(test.expected_ast.errors) ||