-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Expand file tree
/
Copy pathindex.html
More file actions
49 lines (40 loc) · 1.22 KB
/
index.html
File metadata and controls
49 lines (40 loc) · 1.22 KB
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
<!DOCTYPE html >
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Test Suite</title>
<link rel="stylesheet" href="https://code.jquery.com/qunit/qunit-2.13.0.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/brython/3.9.0/brython.min.js" defer></script>
<script src="https://code.jquery.com/qunit/qunit-2.13.0.js"></script>
</head>
<body onload="brython(1)">
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script type="text/python">
from browser import window
def python_add(a, b):
return a + b
window.py_add = python_add
print("After python_add to JS")
</script>
<script>
const js_add = (a, b) => a + b;
QUnit.module('js_add_test', function() {
QUnit.test('should add two numbers', function(assert) {
assert.equal(js_add(1, 1), 2, '1 + 1 = 2');
});
});
QUnit.module('py_add_test', function() {
QUnit.test('should add two numbers in Brython', function(assert) {
assert.equal(py_add(2, 3), 5, '2 + 3 = 5 (python)');
});
});
QUnit.module('py_add_failed_test', function() {
QUnit.test('should add two numbers in Brython (failure)', function(assert) {
assert.equal(py_add(2, 3), 6, '2 + 3 != 6 (python)');
});
});
</script>
</body>
</html>