56 lines
1.3 KiB
HTML
56 lines
1.3 KiB
HTML
<html>
|
|
<head>
|
|
<title>Examples - Fibonacci</title>
|
|
</head>
|
|
<body>
|
|
<h1>Fibonacci</h1>
|
|
|
|
<a href="index.html">List</a> - <a href="fib.py.html">Source</a> - <a href="fib.wat.html">WebAssembly</a>
|
|
|
|
<div style="white-space: pre;" id="results"></div>
|
|
|
|
|
|
<script type="text/javascript" src="./include.js"></script>
|
|
<script type="text/javascript">
|
|
let importObject = {};
|
|
|
|
function run_test(app, number, expected)
|
|
{
|
|
let actual = app.instance.exports.fib(BigInt(number));
|
|
console.log(actual);
|
|
|
|
test_result(BigInt(expected) == actual, {
|
|
'summary': 'fib(' + number + ')',
|
|
'attributes': {
|
|
'expected': expected,
|
|
'actual': actual
|
|
},
|
|
});
|
|
}
|
|
|
|
WebAssembly.instantiateStreaming(fetch('fib.wasm'), importObject)
|
|
.then(app => {
|
|
// 92: 7540113804746346429
|
|
// i64: 9223372036854775807
|
|
// 93: 12200160415121876738
|
|
|
|
run_test(app, 1, '1');
|
|
run_test(app, 2, '1');
|
|
run_test(app, 3, '2');
|
|
run_test(app, 4, '3');
|
|
run_test(app, 10, '55');
|
|
run_test(app, 20, '6765');
|
|
run_test(app, 30, '832040');
|
|
run_test(app, 40, '102334155');
|
|
run_test(app, 50, '12586269025');
|
|
run_test(app, 60, '1548008755920');
|
|
run_test(app, 70, '190392490709135');
|
|
run_test(app, 80, '23416728348467685');
|
|
run_test(app, 90, '2880067194370816120');
|
|
run_test(app, 92, '7540113804746346429');
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|