Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port to cljs - wip #5

Closed
wants to merge 1 commit into from
Closed

port to cljs - wip #5

wants to merge 1 commit into from

Conversation

shaunlebron
Copy link

This isn't complete! Just wanted to start it for anyone wanting to take the baton. (context)

changes:

  • renamed extension from .clj to .cljc (to mark cross-compatibility with clojure and clojurescript)
  • added parseInt and exception wrappers to handle platform differences
  • commented out the main function and test fixture runner for now (can't run in browser)
  • added (run-tests) at end of file
  • replaced with-test with :test (fn [] ...) (not available in cljs)
  • create test/test.cljc for running tests on node or jvm (file loading for test fixtures will be different)
  • create cli.clj for the CLI command for server-side running (no reason to port this to cljs)
  • export the main core functions for use in the browser (should work fine as is)
  • fix the integer handling (see failing tests below)

running tests:

  • brew install clojure (new official clojure cli tool)
  • clj -m wah.core (run clojure tests)
  • clj -m cljs.main -c wah.core --repl (run cljs tests, check command line output, not browser)

ClojureScript tests are failing because 1 is interpreted as a float:

Testing wah.core

FAIL in (maybe-expand-number) (cljs/test.js:433:14)
expected: (= (maybe-expand-number 1) (quote (i32.const 1)))
  actual: (not (= (f64.const 1) (i32.const 1)))

FAIL in (wah-func-to-wasm) (cljs/test.js:433:14)
expected: (= (quote (i32.add_s (i32.const 0) (i32.const 0))) (wah-func-to-wasm {} (quote (0 + 0))))
  actual: (not (= (i32.add_s (i32.const 0) (i32.const 0)) (f64.add (f64.const 0) (f64.const 0))))

FAIL in (wah-func-to-wasm) (cljs/test.js:433:14)
expected: (= (quote (i32.add_s (i32.const 0) (i32.add_s (i32.const 0) (i32.const 1)))) (wah-func-to-wasm {} (quote (0 + (0 + 1)))))
  actual: (not (= (i32.add_s (i32.const 0) (i32.add_s (i32.const 0) (i32.const 1))) (f64.add (f64.const 0) (f64.add (f64.const 0) (f64.const 1)))))

FAIL in (wah-func-to-wasm) (cljs/test.js:433:14)
expected: (= (quote i32) (get (meta (second (wah-func-to-wasm {} (quote (0 + 0))))) :type))
  actual: (not (= i32 f64))

FAIL in (wah-func-to-wasm) (cljs/test.js:433:14)
expected: (= (quote i32) (get (meta (second (wah-func-to-wasm {} (quote (0 + 0))))) :type))
  actual: (not (= i32 f64))

Ran 16 tests containing 43 assertions.
5 failures, 0 errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant