mirror of https://github.com/pyodide/pyodide.git
42 lines
1.3 KiB
HTML
42 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<!-- Quick and dirty tests... Not useful for anything else. -->
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
</head>
|
|
<body>
|
|
<script src='python.asm.js'></script>
|
|
<script>
|
|
/* window.pyexec = Module.cwrap('PyRun_SimpleString', 'number', ['string']);*/
|
|
|
|
var doTest = function(code) {
|
|
var x = Module.runPython(code);
|
|
console.log("------")
|
|
console.log(code)
|
|
console.log("Return type " + typeof x)
|
|
console.log(JSON.stringify(x))
|
|
console.log()
|
|
}
|
|
|
|
|
|
var onReady = function() {
|
|
doTest("42");
|
|
doTest("42.0");
|
|
doTest("[0, 1, 32.0]")
|
|
doTest("{'foo': 42}")
|
|
doTest("'This is a string'")
|
|
doTest("def foo():\n return 42\n\nfoo()")
|
|
doTest("import sys\nsys.platform")
|
|
};
|
|
|
|
// Wait for the module to be ready before calling any functions.
|
|
var interval = setInterval(function () {
|
|
if (Module.calledRun) {
|
|
window.clearInterval(interval);
|
|
onReady();
|
|
}
|
|
}, 100);
|
|
</script>
|
|
</body>
|
|
</html>
|