Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
58 lines (46 loc) · 1.77 KB

File metadata and controls

58 lines (46 loc) · 1.77 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/// <reference path="../../built/pxtcompiler.d.ts"/>
import * as fs from 'fs';
import * as path from 'path';
import "mocha";
import * as chai from "chai";
import * as util from "../common/testUtils";
const casesDir = path.join(process.cwd(), "tests", "tutorial-test", "cases");
const baselineDir = path.join(process.cwd(), "tests", "tutorial-test", "baselines");
// Just needs to exist
pxt.setAppTarget(util.testAppTarget);
describe("tutorial test cases", () => {
const filenames: string[] = [];
for (const file of fs.readdirSync(casesDir)) {
if (file[0] == ".") {
continue;
}
const filename = path.join(casesDir, file)
if (file.substr(-3) === ".md") {
filenames.push(filename)
}
};
filenames.forEach(filename => {
it("should correctly parse " + path.basename(filename), () => {
tutorialTest(filename)
});
});
});
function tutorialTest(filename: string) {
const input = fs.readFileSync(filename, "utf8");
const basename = path.basename(filename).slice(0, -3) + ".json";
const baselinePath = path.join(baselineDir, basename);
let info = pxt.tutorial.parseTutorial(input);
let baseline;
try {
baseline = JSON.parse(fs.readFileSync(baselinePath, "utf8"));
}
catch (e) {
// If there isn't a baseline, generate one.
let newBaseline = info;
fs.writeFileSync(path.join(casesDir, basename + ".local"), JSON.stringify(newBaseline, null, 4));
}
baseline = baseline || info;
let err = pxt.Util.deq(baseline, info);
if (err) fs.writeFileSync(path.join(casesDir, basename + ".err"), JSON.stringify(info, null, 4));
chai.assert(err === null, `Parsed tutorial did not match baseline. See ${basename}.err for details.`);
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.