-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparseError-test.ts
121 lines (118 loc) · 4.23 KB
/
parseError-test.ts
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
* SPDX-FileCopyrightText: Copyright 2023 Roland Csaszar
* SPDX-License-Identifier: MIT
*
* Project: vscode-scheme-repl
* File: parseError-test.ts
* Date: 11.Jun.2023
*
* =============================================================================
* Tests the parsing of error messages when trying to load a file into the REPL.
*/
/* eslint-disable max-statements */
/* eslint-disable max-lines-per-function */
import * as chai from "chai";
import * as e from "../src/evalREPL";
import * as fixture from "../test/fixtures/fileParseErrors";
import * as mocha from "mocha";
import { rangeFromPositions } from "../src/helpers";
/**
* *****************************************************************************
* Tests
*/
mocha.describe("Error parsing functions", () => {
//==========================================================================
mocha.describe("parseError", () => {
mocha.it("Empty string", () => {
chai.assert.deepEqual(
e.parseError({ stderr: "", stdout: "" }, ""),
rangeFromPositions([0, 0], [0, 0]),
"Missing parenthesis returns start position == end position"
);
});
mocha.it("Missing parenthesis", () => {
chai.assert.deepEqual(
e.parseError(
fixture.excMissingParen,
fixture.excMissingParenText
),
fixture.excMissingParenExp,
"Missing parenthesis returns start position == end position"
);
});
mocha.it("Unbound variable", () => {
chai.assert.deepEqual(
e.parseError(fixture.excNotBound, fixture.excNotBoundText),
fixture.excNotBoundExp,
"Unbound variable -> line 17, 23 - 28"
);
});
mocha.it("Invalid syntax", () => {
chai.assert.deepEqual(
e.parseError(
fixture.excInvalidSyntax,
fixture.excInvalidSyntaxText
),
fixture.excInvalidSyntaxExp,
"Invalid syntax -> line 30 col 1"
);
});
mocha.it("R6RS instead of Chezscheme", () => {
chai.assert.deepEqual(
e.parseError(fixture.excWrongLib, fixture.excWrongLibText),
fixture.excWrongLibExp,
"R6RS instead of Chezscheme -> line 24 col 2"
);
});
mocha.it("Wrong number of arguments", () => {
chai.assert.deepEqual(
e.parseError(
fixture.excWrongNumArg,
fixture.excWrongNumArgText
),
fixture.excWrongNumArgExp,
"Wrong number of arguments -> line 32 col 1"
);
});
mocha.it("Wrong number of arguments 2", () => {
chai.assert.deepEqual(
e.parseError(
fixture.excWrongNumArg2,
fixture.excWrongNumArg2Text
),
fixture.excWrongNumArg2Exp,
"Wrong number of arguments 2 -> line 32 col 1"
);
});
mocha.it("Apply non procedure", () => {
chai.assert.deepEqual(
e.parseError(
fixture.excApplyNonProc,
fixture.excApplyNonProcText
),
fixture.excApplyNonProcExp,
"Apply non procedure -> line 47 col 0-3"
);
});
mocha.it("Not an environment", () => {
chai.assert.deepEqual(
e.parseError(
fixture.excNotAnEnvironment,
fixture.excNotAnEnvironmentText
),
fixture.excNotAnEnvironmentExp,
"Not an environment -> line 60 col 0-23"
);
});
mocha.it("Not an environment 2", () => {
chai.assert.deepEqual(
e.parseError(
fixture.excNotAnEnvironment2,
fixture.excNotAnEnvironment2Text
),
fixture.excNotAnEnvironment2Exp,
"Not an environment 2 -> line 60 col 0-23"
);
});
});
});