chiark / gitweb /
make chedk
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 4 Oct 2020 23:55:48 +0000 (00:55 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 4 Oct 2020 23:55:48 +0000 (00:55 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
.gitignore
Makefile
templates/bigfloat-tests.ts

index 1fb4a99eafc940de7db7f3eb879f37fce80450f0..41bbff84d5ec432b6b64851b68b488c2b5f3e82c 100644 (file)
@@ -1,4 +1,5 @@
 templates/script.js
+templates/bigfloat-tests.js
 templates/LICENCE
 templates/AGPLv3
 templates/CC-BY-SA-3.0
index c16606f62b1a124084573980fc5e7c74c73689ec..2e445ad72a3ab08fbdeb7addf095f9ad7ab3cad1 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -65,6 +65,9 @@ cargo-debug cargo-release:: cargo-%: $(CARGO_TARGET_DIR)/%/server
 .PHONY: $(CARGO_TARGET_DIR)/debug/server
 .PHONY: $(CARGO_TARGET_DIR)/release/server
 
+check: cargo-check js-check
+       @echo 'All tests passed.'
+
 extra-debug:
 extra-release: bundled-sources
 
@@ -74,14 +77,24 @@ $(CARGO_TARGET_DIR)/bundled-sources: $(BUNDLE_SOURCES)
        @echo Bundled sources.
 .PHONY: bundle-sources $(CARGO_TARGET_DIR)/bundled-sources
 
+cargo-check:
+       $(CARGO) test
+
 $(CARGO_TARGET_DIR)/debug/server:
        $(CARGO) build
 
 $(CARGO_TARGET_DIR)/release/server:
        $(CARGO) build --release
 
-templates/script.js: tsc-wrap tsconfig.json $(TS_SRC_FILES)
-       ./tsc-wrap $@ tsconfig.json $(TS_SRC_FILES)
+templates/%.js: tsc-wrap tsconfig.json
+       ./tsc-wrap $@ tsconfig.json $(filter %.ts,$^)
+
+templates/script.js: $(TS_SRC_FILES)
+templates/bigfloat-tests.js: templates/bigfloat.ts templates/bigfloat-tests.ts
+
+js-check: templates/bigfloat-tests.js
+       nodejs <$<
+       @echo 'nodejs check $< ok'
 
 DEPLOY_ARCH=x86_64-unknown-linux-musl
 DEPLOY_RELEASE=debug
index bc87f45a859924279f4ab651eae3d80ef5e7756b..40652a2739715cfdf67abcba2719b1741929eebf 100644 (file)
@@ -3,13 +3,15 @@
 // SPDX-License-Identifier: AGPL-3.0-or-later
 // There is NO WARRANTY.
 
-function assert_eq(a,b) { if (a != b) throw('unequal ' + a + ' ' + b); }
+function assert_eq(a: string, b: string) {
+  if (a != b) throw('unequal ' + a + ' ' + b);
+}
 
-x = "!0000 ffff_ffff_fff0";
-y = "!0000 0000_0000_0040";
-i = Bigfloats.iter_upto(x, y, 4);
+let x = "!0000 ffff_ffff_fff0" as any;
+let y = "!0000 0000_0000_0040" as any;
+let i = Bigfloats.iter_upto(x, y, 4);
 
 assert_eq(i(), "+0000 0000_0000_0000");
 assert_eq(i(), "+0000 0000_0000_0010");
 assert_eq(i(), "+0000 0000_0000_0020");
-assert_eq(i(), "+0000x 0000_0000_0030");
+assert_eq(i(), "+0000 0000_0000_0030");