Skip to content

Commit

Permalink
wasm/grains: 2nd iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
vpayno committed Nov 11, 2023
1 parent 6a7b949 commit a10a004
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 42 deletions.
4 changes: 2 additions & 2 deletions wasm/grains/coverage/clover.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<coverage generated="1699635296047" clover="3.2.0">
<project timestamp="1699635296047" name="All files">
<coverage generated="1699667927006" clover="3.2.0">
<project timestamp="1699667927006" name="All files">
<metrics statements="0" coveredstatements="0" conditionals="0" coveredconditionals="0" methods="0" coveredmethods="0" elements="0" coveredelements="0" complexity="0" loc="0" ncloc="0" packages="0" files="0" classes="0"/>
</project>
</coverage>
2 changes: 1 addition & 1 deletion wasm/grains/coverage/lcov-report/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ <h1>All files</h1>
<div class='footer quiet pad2 space-top1 center small'>
Code coverage generated by
<a href="https://istanbul.js.org/" target="_blank" rel="noopener noreferrer">istanbul</a>
at 2023-11-10T16:54:56.045Z
at 2023-11-11T01:58:47.004Z
</div>
<script src="prettify.js"></script>
<script>
Expand Down
19 changes: 17 additions & 2 deletions wasm/grains/grains.wat
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,22 @@

;; Result is unsigned i64
(func (export "total") (result i64)
;; let it wrap to get the highest value
(i64.const -1)
;; let it wrap to get the highest value (u64::MAX)
;; (i64.const -1)

;; ((((1_u64) << 63) - 1) << 1) + 1
(i64.add
(i64.shl
(i64.sub
(i64.shl
(i64.const 1)
(i64.const 63)
) ;; shl
(i64.const 1)
) ;; sub
(i64.const 1)
) ;; shl
(i64.const 1)
) ;; add
)
)
74 changes: 37 additions & 37 deletions wasm/grains/run-tests-wasm.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,38 @@ Node versions:

Running: js-beautify ./babel.config.js ./grains.spec.js

beautified babel.config.js
beautified grains.spec.js
beautified babel.config.js - unchanged
beautified grains.spec.js - unchanged

real 0m0.086s
user 0m0.090s
sys 0m0.011s
user 0m0.084s
sys 0m0.015s


==============================================================================

Exit code: 0

real 0m0.398s
user 0m0.396s
sys 0m0.065s
real 0m0.390s
user 0m0.373s
sys 0m0.079s

real 0m0.402s
user 0m0.397s
sys 0m0.067s
real 0m0.393s
user 0m0.376s
sys 0m0.079s

===============================================================================

Running: npm install

up to date in 489ms
up to date in 533ms

107 packages are looking for funding
run `npm fund` for details

real 0m0.650s
user 0m0.868s
sys 0m0.083s
real 0m0.698s
user 0m0.947s
sys 0m0.077s

===============================================================================

Expand All @@ -70,8 +70,8 @@ Running: rm -rf ./coverage


real 0m0.001s
user 0m0.000s
sys 0m0.001s
user 0m0.001s
sys 0m0.000s


==============================================================================
Expand All @@ -82,22 +82,22 @@ Running: npm run test -- --coverage
> test
> node --experimental-vm-modules node_modules/jest/bin/jest.js ./* --coverage

(node:21762) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time
(node:28458) ExperimentalWarning: VM Modules is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
PASS ./grains.spec.js
Grains
✓ returns the total number of grains on the board (1 ms)
✓ returns the total number of grains on the board
returns the number of grains on the square
✓ grains on square 1 (1 ms)
✓ grains on square 1 (2 ms)
✓ grains on square 2
✓ grains on square 3
✓ grains on square 4 (1 ms)
✓ grains on square 16
✓ grains on square 32 (1 ms)
✓ grains on square 3 (1 ms)
✓ grains on square 4
✓ grains on square 16 (1 ms)
✓ grains on square 32
✓ grains on square 64
✓ square 0 has no value
✓ negative square has no value
✓ square greater than 64 has no value
✓ square greater than 64 has no value (1 ms)

----------|---------|----------|---------|---------|-------------------
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
Expand All @@ -107,33 +107,33 @@ All files | 0 | 0 | 0 | 0 |
Test Suites: 1 passed, 1 total
Tests: 11 passed, 11 total
Snapshots: 0 total
Time: 0.545 s, estimated 1 s
Time: 0.314 s, estimated 1 s
Ran all test suites matching /.\/HELP.md|.\/LICENSE|.\/README.md|.\/babel.config.js|.\/grains.spec.js|.\/grains.wat|.\/node_modules|.\/package-lock.json|.\/package.json|.\/run-tests-wasm.txt/i.

real 0m1.141s
user 0m1.144s
sys 0m0.150s
real 0m0.925s
user 0m0.908s
sys 0m0.111s


==============================================================================

Exit code: 0

real 0m1.441s
user 0m1.436s
sys 0m0.205s
real 0m1.245s
user 0m1.248s
sys 0m0.179s

real 0m1.443s
user 0m1.437s
sys 0m0.205s
real 0m1.248s
user 0m1.250s
sys 0m0.180s

===============================================================================

Running: misspell ./grains.wat

real 0m0.034s
user 0m0.037s
sys 0m0.015s
real 0m0.037s
user 0m0.047s
sys 0m0.011s

===============================================================================

Expand Down

0 comments on commit a10a004

Please sign in to comment.