Skip to content

Commit 3002fb3

Browse files
committed
Implement syntax check for javascript
Also added some examples to test that a syntax error does trigger an COMPILER-ERROR. This does also require another extension as we can't load modules with the normal extension without a package.json file.
1 parent 34f62be commit 3002fb3

File tree

19 files changed

+88
-1
lines changed

19 files changed

+88
-1
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This should give CORRECT on the default problem 'hello'.
2+
// It does include another file for the actual implementation
3+
//
4+
// @EXPECTED_RESULTS@: CORRECT
5+
6+
import { hello } from './module.js';
7+
console.log(hello());
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Extra included file with JS code
2+
export function hello() {
3+
return "Hello world!";
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"type": "module"}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This should give CORRECT on the default problem 'hello'.
2+
// It does include another file for the actual implementation
3+
//
4+
// @EXPECTED_RESULTS@: CORRECT
5+
6+
import { hello } from './module.mjs';
7+
console.log(hello());
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Extra included file with JS code
2+
export function hello() {
3+
return "Hello world!";
4+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This should give COMPILER-ERROR on the default problem 'hello'.
2+
// The console.log is missing a `)`.
3+
//
4+
// @EXPECTED_RESULTS@: COMPILER-ERROR
5+
6+
import { hello } from './module.js';
7+
console.log(hello();
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// Extra included file with JS code
2+
export function hello() {
3+
return "Hello world!";
4+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"type": "module"}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// This should give CORRECT on the default problem 'hello'.
2+
// The submission includes another file with invalid syntax
3+
// which is never used. As we check all files for syntax we
4+
// also check the unused but invalid other file resulting in
5+
// the (unneeded) error.
6+
//
7+
// @EXPECTED_RESULTS@: COMPILER-ERROR
8+
9+
console.log("Hello world!");
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Extra included file with (invalid) JS code.
2+
// Invalid syntax on import instead of export.
3+
// The file itself is never used in the submission.
4+
import function hello() {
5+
return "Hello world!"
6+
}

0 commit comments

Comments
 (0)