Skip to content

Commit

Permalink
Merge 68cbd74 into 5e2d9bb
Browse files Browse the repository at this point in the history
  • Loading branch information
thomastanck committed Jul 27, 2020
2 parents 5e2d9bb + 68cbd74 commit 0d5a75b
Show file tree
Hide file tree
Showing 7 changed files with 6,834 additions and 16 deletions.
14 changes: 14 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ node_js:
branches:
except:
- /^no-ci.*$/
services:
- xvfb
# before_install:
# - sudo apt-get update -qq;
# sudo apt-get install -y --no-install-recommends libcairo2-dev build-essential libxi-dev libglu1-mesa-dev libglew-dev pkg-config
# before_install:
# - if [ $TRAVIS_OS_NAME == linux ]; then
# sudo apt-get update -qq;
# sudo apt-get install -y --no-install-recommends libxrandr-dev libxi-dev libxxf86vm-dev libsdl2-dev;
# wget https://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.zip;
# unzip glfw-3.2.1.zip && cd glfw-3.2.1;
# cmake -DBUILD_SHARED_LIBS=true -DGLFW_BUILD_EXAMPLES=false -DGLFW_BUILD_TESTS=false -DGLFW_BUILD_DOCS=false .;
# sudo make -j $CPU_NUM install && cd ..;
# fi
script:
- yarn run test-coveralls
- yarn run typecheck
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
},
"dependencies": {
"js-slang": "^0.4.57",
"lodash": "4.17.19"
"lodash": "4.17.19",
"node-canvas-webgl": "^0.2.6"
},
"devDependencies": {
"@types/jest": "^26.0.7",
Expand Down
94 changes: 94 additions & 0 deletions src/__tests__/test_rune.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { awsEventFactory } from "./helpers";
import { runAll } from "../index";

const makeAwsEvent = awsEventFactory({
chapter: 2,
external: {
name: "RUNES",
symbols: [
"heart",
"square",
"nova",
"beside",
"stack",
"show",
"picture_mse",
"getReadyWebGLForCanvas",
],
},
globals: [],
});

test("rune correct", async () => {
const results = await runAll(
makeAwsEvent({
prependProgram: "getReadyWebGLForCanvas('2d');",
studentProgram: "",
postpendProgram: "",
testcases: [
{
program: `
picture_mse(show(square), show(square)) < 0.01;
`,
answer: "true",
score: 1,
},
{
program: `
picture_mse(show(stack(square, square)), show(beside(square, square))) < 0.01;
`,
answer: "true",
score: 1,
},
{
program: `
picture_mse(show(square), show(beside(square, square))) < 0.01;
`,
answer: "true",
score: 1,
},
{
program: `
picture_mse(show(heart), show(beside(square, square))) < 0.01;
`,
answer: "false",
score: 1,
},
{
program: `
picture_mse(show(heart), show(nova)) < 0.01;
`,
answer: "false",
score: 1,
},
],
})
);
expect(results).toMatchInlineSnapshot(`
Object {
"results": Array [
Object {
"resultType": "pass",
"score": 1,
},
Object {
"resultType": "pass",
"score": 1,
},
Object {
"resultType": "pass",
"score": 1,
},
Object {
"resultType": "pass",
"score": 1,
},
Object {
"resultType": "pass",
"score": 1,
},
],
"totalScore": 5,
}
`);
});
Loading

0 comments on commit 0d5a75b

Please sign in to comment.