-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial web tests * Add new action for node and web lib tests.
- Loading branch information
Showing
7 changed files
with
118 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
FUTHARK_BACKEND ?= wasm | ||
|
||
.PHONY: test clean | ||
|
||
test: npm_install do_test_square | ||
|
||
do_test_%: %.test.js %.mjs | ||
jest $*.test.js | ||
|
||
%.mjs: %.fut | ||
futhark $(FUTHARK_BACKEND) --library $^ | ||
|
||
clean: | ||
rm -rf *.c *.h *.class.js *.wasm *.mjs | ||
|
||
npm_install: | ||
npm install | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// jest-puppeteer.config.js | ||
module.exports = { | ||
server: { | ||
command: 'python3 -m http.server 8000', | ||
port: 8000 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"scripts": { | ||
"test": "jest" | ||
}, | ||
"name": "web-tests", | ||
"jest": { | ||
"preset": "jest-puppeteer", | ||
"verbose": true | ||
}, | ||
"dependencies": { | ||
"jest-puppeteer": "^5.0.4", | ||
"puppeteer": "^9.1.1", | ||
"puppeteer-core": "^9.1.1" | ||
}, | ||
"devDependencies": { | ||
"jest": "^27.0.6", | ||
"jest-cli": "^27.0.6", | ||
"jest-dev-server": "^5.0.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
entry square (x : i32) = x * x | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<!doctype html> | ||
<html> | ||
<label for="square">Number to Square:</label><br> | ||
<input type="text" value="37" id="square_id" name="square"><br> | ||
|
||
<p id="result"></p> | ||
|
||
<script type="module"> | ||
|
||
import { newFutharkContext } from './square.mjs'; | ||
var fc; | ||
newFutharkContext().then(fc => { | ||
function myFunction() { | ||
var num_text = document.getElementById("square_id").value; | ||
var num = parseInt(num_text); | ||
var keep = fc.square(num); | ||
document.getElementById("result").innerHTML = keep; | ||
} | ||
myFunction(); | ||
}); | ||
|
||
// Call Futhark function | ||
|
||
</script> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
require('expect-puppeteer'); | ||
|
||
describe('Futhark entry point : square test', () => { | ||
beforeAll(async () => { | ||
await page.goto('http://localhost:8000/square.html') | ||
}) | ||
|
||
it('should display "1369" text on page', async () => { | ||
await expect(page).toMatch('1369') | ||
}) | ||
}) |