mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-17 23:11:23 +00:00
Speed up Travis by running Webpack in fewer tests (#381)
* Reorganize Travis configuration * Add a `JOB` env var descriptor to all matrix entries. Not used anywhere but is useful when viewing the whole build on Travis's web interface. * Reorganize where builds are located, moving slow builds first and fast ones last. * Change checking the CLI builds from `cargo build` to `cargo check` * Use YAML references to reduce some duplication * Print some more timing statistics for each test * Extract `Project` helper in tests to a module This'll help make it a bit more extensible over time. At the same time the methods are also slightly reorganized to read more clearly from top to bottom. * Migrate all tests away from Webpack Wepback can take a significant amount of time to execute and when it's multiplied by hundreds of tests that adds up really quickly! After investigating Node's `--experimental-modules` option it looks like it's suitable for our use so this switches all tests to using JS files (moving away from TypeScript as well) with `--experimental-modules` with Node. Tests will be selectively re-enabled with webpack and node.js specific output (that doesn't require `--experimental-modules`), coming in later commits. * Restore the node test for node.js output Ensures it's workable as-is * Only generate typescript with webpack * Only read wasm files for webpack * Skip package.json/node_modules for now * Only generate webpack config if needed * Start a dedicated test module for typescript Will hopefully verify the generated Typescript compiles OK. * Remove unneeded `node` method * Fixup some rebase conflicts * Don't run asmjs example on travis * Fixup generator tests * Attempt to fix windows * Comment windows fix * More test fixes * More exclusions * More test fixes * Relax eslint regex Catch mjs modules as well * Fix eslint * Speed up travis on examples slightly
This commit is contained in:
@ -6,6 +6,7 @@ module.exports = {
|
||||
node: true
|
||||
},
|
||||
extends: 'eslint:recommended',
|
||||
parser: 'babel-eslint',
|
||||
parserOptions: {
|
||||
sourceType: 'module'
|
||||
},
|
||||
|
148
.travis.yml
148
.travis.yml
@ -1,20 +1,38 @@
|
||||
language: rust
|
||||
sudo: false
|
||||
|
||||
matrix:
|
||||
include:
|
||||
# CLI builds on stable
|
||||
- rust: stable
|
||||
install: true
|
||||
script: cargo build --manifest-path crates/cli/Cargo.toml
|
||||
|
||||
# Tests pass on nightly
|
||||
- rust: nightly
|
||||
before_install:
|
||||
INSTALL_NODE_VIA_NVM: &INSTALL_NODE_VIA_NVM
|
||||
- rustup target add wasm32-unknown-unknown
|
||||
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
|
||||
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
|
||||
- source ~/.nvm/nvm.sh
|
||||
- nvm install v10.5
|
||||
|
||||
|
||||
DEPLOY_TO_GITHUB: &DEPLOY_TO_GITHUB
|
||||
before_deploy:
|
||||
|
|
||||
name="wasm-bindgen-$TRAVIS_TAG-$TARGET"
|
||||
mkdir "$name"
|
||||
cp "target/$TARGET/release/{wasm-bindgen,wasm2es6js}" "$name/"
|
||||
cp README.md LICENSE-MIT LICENSE-APACHE "$name/"
|
||||
tar czvf "$name.tar.gz" "$name"
|
||||
deploy:
|
||||
api_key:
|
||||
secure: "qCiELnEnvyKpWHDttgTNf+ElZGbWlvthu5aOIj5nYfov+h6g1+mkWnDFP6at/WPlE78zE/f/z/dL2KB2I7w/cxH/T4P1nWh0A9DvrpY6hqWkK2pgN5dPeWE/a4flI7AdH0A6wMRw7m00uMgDjlzN78v7XueccpJCxSO5allQN5jweAQvMX2QA07TbLRJc7Lq6lfVwSf8OfrcO8qCbcIzJTsC4vtbh6jkUYg1OAaU2tAYlskBy9ZYmHWCExIAu/zxzcJY9OpApPD9Ea4CyrsfjniAyRBJ87Weh/sP4XhiWeRPVmvA4HAzv4Pps9ps+Ar5QmsX53rhKQ3id7/VPR8ggaAHxrYUiJPvJRtbP6cKKOlDiK0ooP+vI4vjxWeNVj9ibEolSYOlT0ENIvPK1BppA6VgAoJOjwPr0Q16Ma4AmvLkIkowJiXCm2Jlje/5c0vPEAGJVgUtkj3jFQzgXwyEMpzxUlhHmYpmnfeaM0tK/Kiiwe1monL/ydMlyfV55kNylylCg+XoTnf420AFChKbD4DM5Z7ZsjU9g8fF3LUoN0sKpmLDp+GvwjLi9YtGogWB71Q2MFp43MSL0YLshkyYYoZKrVMiy5J9hKNUxhT2jNEq53Z69syIHHMCxHL9GoAcuHxIKOA7uTMW0aCoyy2I+dfAKKsrUGwGYaNC5LZdUQI="
|
||||
file_glob: true
|
||||
file:
|
||||
- wasm-bindgen-$TRAVIS_TAG-$TARGET.tar.gz
|
||||
on:
|
||||
tags: true
|
||||
provider: releases
|
||||
skip_cleanup: true
|
||||
|
||||
matrix:
|
||||
include:
|
||||
# Tests pass on nightly
|
||||
- rust: nightly
|
||||
env: JOB=test-bindgen
|
||||
before_install: *INSTALL_NODE_VIA_NVM
|
||||
install:
|
||||
# dirties git repository, there doesn't seem to be a way to resolve this other than
|
||||
# to run `npm install` twice or by using `npm ci` (which is currently broken)
|
||||
@ -22,82 +40,68 @@ matrix:
|
||||
script:
|
||||
- cargo test
|
||||
# Check JS output from all tests against eslint
|
||||
- ./node_modules/.bin/eslint ./target/generated-tests/*/out*.js
|
||||
env: RUST_BACKTRACE=1
|
||||
- ./node_modules/.bin/eslint ./target/generated-tests/*/out*js
|
||||
|
||||
# All examples work
|
||||
- rust: nightly
|
||||
env: JOB=examples-build
|
||||
install: *INSTALL_NODE_VIA_NVM
|
||||
script:
|
||||
- mkdir node_modules
|
||||
- |
|
||||
for dir in `ls examples | grep -v README | grep -v asm.js | grep -v no_modules`; do
|
||||
(cd examples/$dir &&
|
||||
sed -i 's/: "webpack-dev-server"/: "webpack"/' package.json &&
|
||||
ln -s ../../node_modules . &&
|
||||
./build.sh) || exit 1;
|
||||
done
|
||||
|
||||
# Tests pass on nightly using yarn
|
||||
- rust: nightly
|
||||
before_install:
|
||||
- rustup target add wasm32-unknown-unknown
|
||||
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
|
||||
- source ~/.nvm/nvm.sh
|
||||
- nvm install v10.5
|
||||
env: JOB=test-yarn-smoke
|
||||
before_install: *INSTALL_NODE_VIA_NVM
|
||||
install:
|
||||
- curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 1.7.0
|
||||
- export PATH=$HOME/.yarn/bin:$PATH
|
||||
install:
|
||||
- yarn install --freeze-lockfile
|
||||
script:
|
||||
- cargo test
|
||||
# Check JS output from all tests against eslint
|
||||
- ./node_modules/.bin/eslint ./target/generated-tests/*/out*.js
|
||||
env: RUST_BACKTRACE=1
|
||||
script: cargo test api::works
|
||||
|
||||
# WebIDL tests pass on nightly
|
||||
- rust: nightly
|
||||
env: JOB=test-webidl
|
||||
before_install: rustup component add rustfmt-preview --toolchain nightly
|
||||
script: (cd crates/webidl && cargo test)
|
||||
env: RUST_BACKTRACE=1 RUST_LOG=wasm_bindgen_webidl
|
||||
script: cargo test --manifest-path crates/webidl/Cargo.toml
|
||||
|
||||
# Dist linux binary
|
||||
- env: TARGET=x86_64-unknown-linux-musl DEPLOY=1
|
||||
rust: nightly
|
||||
- rust: nightly
|
||||
env: JOB=dist-linux TARGET=x86_64-unknown-linux-musl
|
||||
before_script: rustup target add $TARGET
|
||||
script: cargo build --manifest-path crates/cli/Cargo.toml --release --target $TARGET
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- musl-tools
|
||||
<<: *DEPLOY_TO_GITHUB
|
||||
|
||||
# Dist OSX binary
|
||||
- os: osx
|
||||
rust: nightly
|
||||
env: MACOSX_DEPLOYMENT_TARGET=10.7 DEPLOY=1 TARGET=x86_64-apple-darwin
|
||||
- rust: nightly
|
||||
os: osx
|
||||
env: JOB=dist-osx MACOSX_DEPLOYMENT_TARGET=10.7 TARGET=x86_64-apple-darwin
|
||||
script: cargo build --manifest-path crates/cli/Cargo.toml --release --target $TARGET
|
||||
install: true
|
||||
<<: *DEPLOY_TO_GITHUB
|
||||
|
||||
# We can build the tool on nightly
|
||||
# CLI builds on stable
|
||||
- rust: stable
|
||||
env: JOB=check-stable-cli
|
||||
script: cargo check --manifest-path crates/cli/Cargo.toml
|
||||
# CLI builds on nightly
|
||||
- rust: nightly
|
||||
script: cargo install --debug --path crates/cli
|
||||
|
||||
# All examples work
|
||||
- rust: nightly
|
||||
before_install:
|
||||
- rustup target add wasm32-unknown-unknown
|
||||
- curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.8/install.sh | bash
|
||||
- source ~/.nvm/nvm.sh
|
||||
- nvm install v10.5
|
||||
script:
|
||||
- |
|
||||
(cd examples/hello_world && sed -i 's/: "webpack-dev-server"/: "webpack"/' package.json && ./build.sh)
|
||||
- |
|
||||
(cd examples/smorgasboard && sed -i 's/: "webpack-dev-server"/: "webpack"/' package.json && ./build.sh)
|
||||
- |
|
||||
(cd examples/console_log && sed -i 's/: "webpack-dev-server"/: "webpack"/' package.json && ./build.sh)
|
||||
- |
|
||||
(cd examples/math && sed -i 's/: "webpack-dev-server"/: "webpack"/' package.json && ./build.sh)
|
||||
- |
|
||||
(cd examples/dom && sed -i 's/: "webpack-dev-server"/: "webpack"/' package.json && ./build.sh)
|
||||
- |
|
||||
(cd examples/wasm-in-wasm && sed -i 's/: "webpack-dev-server"/: "webpack"/' package.json && ./build.sh)
|
||||
- |
|
||||
(cd examples/char && sed -i 's/: "webpack-dev-server"/: "webpack"/' package.json && ./build.sh)
|
||||
- |
|
||||
(cd examples/closures && sed -i 's/: "webpack-dev-server"/: "webpack"/' package.json && ./build.sh)
|
||||
- |
|
||||
(cd examples/comments && sed -i 's/: "webpack-dev-server"/: "webpack"/' package.json && ./build.sh)
|
||||
env: JOB=check-nightly-cli
|
||||
script: cargo check --manifest-path crates/cli/Cargo.toml
|
||||
|
||||
# Build the guide.
|
||||
- rust: stable
|
||||
env: JOB=guide-build-and-deploy
|
||||
cache:
|
||||
- cargo
|
||||
before_script:
|
||||
@ -119,25 +123,3 @@ matrix:
|
||||
notifications:
|
||||
email:
|
||||
on_success: never
|
||||
|
||||
before_deploy:
|
||||
|
|
||||
if [[ "$DEPLOY" == "1" ]]; then
|
||||
name="wasm-bindgen-$TRAVIS_TAG-$TARGET"
|
||||
mkdir "$name"
|
||||
cp "target/$TARGET/release/{wasm-bindgen,wasm2es6js}" "$name/"
|
||||
cp README.md LICENSE-MIT LICENSE-APACHE "$name/"
|
||||
tar czvf "$name.tar.gz" "$name"
|
||||
fi
|
||||
|
||||
deploy:
|
||||
api_key:
|
||||
secure: "qCiELnEnvyKpWHDttgTNf+ElZGbWlvthu5aOIj5nYfov+h6g1+mkWnDFP6at/WPlE78zE/f/z/dL2KB2I7w/cxH/T4P1nWh0A9DvrpY6hqWkK2pgN5dPeWE/a4flI7AdH0A6wMRw7m00uMgDjlzN78v7XueccpJCxSO5allQN5jweAQvMX2QA07TbLRJc7Lq6lfVwSf8OfrcO8qCbcIzJTsC4vtbh6jkUYg1OAaU2tAYlskBy9ZYmHWCExIAu/zxzcJY9OpApPD9Ea4CyrsfjniAyRBJ87Weh/sP4XhiWeRPVmvA4HAzv4Pps9ps+Ar5QmsX53rhKQ3id7/VPR8ggaAHxrYUiJPvJRtbP6cKKOlDiK0ooP+vI4vjxWeNVj9ibEolSYOlT0ENIvPK1BppA6VgAoJOjwPr0Q16Ma4AmvLkIkowJiXCm2Jlje/5c0vPEAGJVgUtkj3jFQzgXwyEMpzxUlhHmYpmnfeaM0tK/Kiiwe1monL/ydMlyfV55kNylylCg+XoTnf420AFChKbD4DM5Z7ZsjU9g8fF3LUoN0sKpmLDp+GvwjLi9YtGogWB71Q2MFp43MSL0YLshkyYYoZKrVMiy5J9hKNUxhT2jNEq53Z69syIHHMCxHL9GoAcuHxIKOA7uTMW0aCoyy2I+dfAKKsrUGwGYaNC5LZdUQI="
|
||||
file_glob: true
|
||||
file:
|
||||
- wasm-bindgen-$TRAVIS_TAG-$TARGET.tar.gz
|
||||
on:
|
||||
condition: $DEPLOY = 1
|
||||
tags: true
|
||||
provider: releases
|
||||
skip_cleanup: true
|
||||
|
@ -60,7 +60,7 @@ impl<'a> Context<'a> {
|
||||
if let Some(ref c) = comments {
|
||||
self.globals.push_str(c);
|
||||
}
|
||||
let global = if self.config.nodejs {
|
||||
let global = if self.use_node_require() {
|
||||
if contents.starts_with("class") {
|
||||
format!("{1}\nmodule.exports.{0} = {0};\n", name, contents)
|
||||
} else {
|
||||
@ -412,12 +412,12 @@ impl<'a> Context<'a> {
|
||||
} else {
|
||||
let import_wasm = if self.globals.len() == 0 {
|
||||
String::new()
|
||||
} else if self.config.nodejs {
|
||||
} else if self.use_node_require() {
|
||||
self.footer
|
||||
.push_str(&format!("wasm = require('./{}_bg');", module_name));
|
||||
format!("var wasm;")
|
||||
} else {
|
||||
format!("import * as wasm from './{}_bg.wasm';", module_name)
|
||||
format!("import * as wasm from './{}_bg';", module_name)
|
||||
};
|
||||
|
||||
format!(
|
||||
@ -977,7 +977,9 @@ impl<'a> Context<'a> {
|
||||
if !self.exposed_globals.insert("text_encoder") {
|
||||
return;
|
||||
}
|
||||
if self.config.nodejs {
|
||||
if self.config.nodejs_experimental_modules {
|
||||
self.imports.push_str("import { TextEncoder } from 'util';\n");
|
||||
} else if self.config.nodejs {
|
||||
self.global(
|
||||
"
|
||||
const TextEncoder = require('util').TextEncoder;
|
||||
@ -1003,7 +1005,9 @@ impl<'a> Context<'a> {
|
||||
if !self.exposed_globals.insert("text_decoder") {
|
||||
return;
|
||||
}
|
||||
if self.config.nodejs {
|
||||
if self.config.nodejs_experimental_modules {
|
||||
self.imports.push_str("import { TextDecoder } from 'util';\n");
|
||||
} else if self.config.nodejs {
|
||||
self.global(
|
||||
"
|
||||
const TextDecoder = require('util').TextDecoder;
|
||||
@ -1585,6 +1589,10 @@ impl<'a> Context<'a> {
|
||||
*section.payload_mut() = contents.into_bytes();
|
||||
self.module.sections_mut().push(Section::Custom(section));
|
||||
}
|
||||
|
||||
fn use_node_require(&self) -> bool {
|
||||
self.config.nodejs && !self.config.nodejs_experimental_modules
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'b> SubContext<'a, 'b> {
|
||||
@ -1944,7 +1952,7 @@ impl<'a, 'b> SubContext<'a, 'b> {
|
||||
let name = import.js_namespace.as_ref().map(|s| &**s).unwrap_or(item);
|
||||
|
||||
if self.cx.imported_names.insert(name.to_string()) {
|
||||
if self.cx.config.nodejs {
|
||||
if self.cx.use_node_require() {
|
||||
self.cx.imports.push_str(&format!(
|
||||
"\
|
||||
const {} = require('{}').{};\n\
|
||||
|
@ -24,6 +24,7 @@ pub mod wasm2es6js;
|
||||
pub struct Bindgen {
|
||||
path: Option<PathBuf>,
|
||||
nodejs: bool,
|
||||
nodejs_experimental_modules: bool,
|
||||
browser: bool,
|
||||
no_modules: bool,
|
||||
no_modules_global: Option<String>,
|
||||
@ -37,6 +38,7 @@ impl Bindgen {
|
||||
Bindgen {
|
||||
path: None,
|
||||
nodejs: false,
|
||||
nodejs_experimental_modules: false,
|
||||
browser: false,
|
||||
no_modules: false,
|
||||
no_modules_global: None,
|
||||
@ -56,6 +58,11 @@ impl Bindgen {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn nodejs_experimental_modules(&mut self, node: bool) -> &mut Bindgen {
|
||||
self.nodejs_experimental_modules = node;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn browser(&mut self, browser: bool) -> &mut Bindgen {
|
||||
self.browser = browser;
|
||||
self
|
||||
@ -162,7 +169,8 @@ impl Bindgen {
|
||||
cx.finalize(stem)?
|
||||
};
|
||||
|
||||
let js_path = out_dir.join(stem).with_extension("js");
|
||||
let extension = if self.nodejs_experimental_modules { "mjs" } else { "js" };
|
||||
let js_path = out_dir.join(stem).with_extension(extension);
|
||||
File::create(&js_path)
|
||||
.and_then(|mut f| f.write_all(reset_indentation(&js).as_bytes()))
|
||||
.with_context(|_| format!("failed to write `{}`", js_path.display()))?;
|
||||
@ -177,7 +185,7 @@ impl Bindgen {
|
||||
let wasm_path = out_dir.join(format!("{}_bg", stem)).with_extension("wasm");
|
||||
|
||||
if self.nodejs {
|
||||
let js_path = wasm_path.with_extension("js");
|
||||
let js_path = wasm_path.with_extension(extension);
|
||||
let shim = self.generate_node_wasm_import(&module, &wasm_path);
|
||||
File::create(&js_path)
|
||||
.and_then(|mut f| f.write_all(shim.as_bytes()))
|
||||
@ -200,22 +208,62 @@ impl Bindgen {
|
||||
}
|
||||
|
||||
let mut shim = String::new();
|
||||
|
||||
if self.nodejs_experimental_modules {
|
||||
for (i, module) in imports.iter().enumerate() {
|
||||
shim.push_str(&format!("import * as import{} from '{}';\n",
|
||||
i, module));
|
||||
}
|
||||
// On windows skip the leading `/` which comes out when we parse a
|
||||
// url to use `C:\...` instead of `\C:\...`
|
||||
shim.push_str(&format!("
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as url from 'url';
|
||||
import * as process from 'process';
|
||||
|
||||
let file = path.dirname(url.parse(import.meta.url).pathname);
|
||||
if (process.platform === 'win32') {{
|
||||
file = file.substring(1);
|
||||
}}
|
||||
const bytes = fs.readFileSync(path.join(file, '{}'));
|
||||
", path.file_name().unwrap().to_str().unwrap()));
|
||||
} else {
|
||||
shim.push_str(&format!("
|
||||
const path = require('path').join(__dirname, '{}');
|
||||
const bytes = require('fs').readFileSync(path);
|
||||
", path.file_name().unwrap().to_str().unwrap()));
|
||||
}
|
||||
shim.push_str("let imports = {};\n");
|
||||
for module in imports {
|
||||
for (i, module) in imports.iter().enumerate() {
|
||||
if self.nodejs_experimental_modules {
|
||||
shim.push_str(&format!("imports['{}'] = import{};\n", module, i));
|
||||
} else {
|
||||
shim.push_str(&format!("imports['{0}'] = require('{0}');\n", module));
|
||||
}
|
||||
}
|
||||
|
||||
shim.push_str(&format!(
|
||||
"
|
||||
const join = require('path').join;
|
||||
const bytes = require('fs').readFileSync(join(__dirname, '{}'));
|
||||
const wasmModule = new WebAssembly.Module(bytes);
|
||||
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
|
||||
module.exports = wasmInstance.exports;
|
||||
",
|
||||
path.file_name().unwrap().to_str().unwrap()
|
||||
));
|
||||
|
||||
if self.nodejs_experimental_modules {
|
||||
if let Some(e) = m.export_section() {
|
||||
for name in e.entries().iter().map(|e| e.field()) {
|
||||
shim.push_str("export const ");
|
||||
shim.push_str(name);
|
||||
shim.push_str(" = wasmInstance.exports.");
|
||||
shim.push_str(name);
|
||||
shim.push_str(";\n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
shim.push_str("module.exports = wasmInstance.exports;\n");
|
||||
}
|
||||
|
||||
reset_indentation(&shim)
|
||||
}
|
||||
}
|
||||
|
519
package-lock.json
generated
519
package-lock.json
generated
@ -2,6 +2,156 @@
|
||||
"requires": true,
|
||||
"lockfileVersion": 1,
|
||||
"dependencies": {
|
||||
"@babel/code-frame": {
|
||||
"version": "7.0.0-beta.44",
|
||||
"resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.44.tgz",
|
||||
"integrity": "sha512-cuAuTTIQ9RqcFRJ/Y8PvTh+paepNcaGxwQwjIDRWPXmzzyAeCO4KqS9ikMvq0MCbRk6GlYKwfzStrcP3/jSL8g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/highlight": "7.0.0-beta.44"
|
||||
}
|
||||
},
|
||||
"@babel/generator": {
|
||||
"version": "7.0.0-beta.44",
|
||||
"resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.0.0-beta.44.tgz",
|
||||
"integrity": "sha512-5xVb7hlhjGcdkKpMXgicAVgx8syK5VJz193k0i/0sLP6DzE6lRrU1K3B/rFefgdo9LPGMAOOOAWW4jycj07ShQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/types": "7.0.0-beta.44",
|
||||
"jsesc": "^2.5.1",
|
||||
"lodash": "^4.2.0",
|
||||
"source-map": "^0.5.0",
|
||||
"trim-right": "^1.0.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"jsesc": {
|
||||
"version": "2.5.1",
|
||||
"resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.1.tgz",
|
||||
"integrity": "sha1-5CGiqOINawgZ3yiQj3glJrlt0f4=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"@babel/helper-function-name": {
|
||||
"version": "7.0.0-beta.44",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.0.0-beta.44.tgz",
|
||||
"integrity": "sha512-MHRG2qZMKMFaBavX0LWpfZ2e+hLloT++N7rfM3DYOMUOGCD8cVjqZpwiL8a0bOX3IYcQev1ruciT0gdFFRTxzg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/helper-get-function-arity": "7.0.0-beta.44",
|
||||
"@babel/template": "7.0.0-beta.44",
|
||||
"@babel/types": "7.0.0-beta.44"
|
||||
}
|
||||
},
|
||||
"@babel/helper-get-function-arity": {
|
||||
"version": "7.0.0-beta.44",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.0.0-beta.44.tgz",
|
||||
"integrity": "sha512-w0YjWVwrM2HwP6/H3sEgrSQdkCaxppqFeJtAnB23pRiJB5E/O9Yp7JAAeWBl+gGEgmBFinnTyOv2RN7rcSmMiw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/types": "7.0.0-beta.44"
|
||||
}
|
||||
},
|
||||
"@babel/helper-split-export-declaration": {
|
||||
"version": "7.0.0-beta.44",
|
||||
"resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.0.0-beta.44.tgz",
|
||||
"integrity": "sha512-aQ7QowtkgKKzPGf0j6u77kBMdUFVBKNHw2p/3HX/POt5/oz8ec5cs0GwlgM8Hz7ui5EwJnzyfRmkNF1Nx1N7aA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/types": "7.0.0-beta.44"
|
||||
}
|
||||
},
|
||||
"@babel/highlight": {
|
||||
"version": "7.0.0-beta.44",
|
||||
"resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.44.tgz",
|
||||
"integrity": "sha512-Il19yJvy7vMFm8AVAh6OZzaFoAd0hbkeMZiX3P5HGD+z7dyI7RzndHB0dg6Urh/VAFfHtpOIzDUSxmY6coyZWQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"chalk": "^2.0.0",
|
||||
"esutils": "^2.0.2",
|
||||
"js-tokens": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"@babel/template": {
|
||||
"version": "7.0.0-beta.44",
|
||||
"resolved": "https://registry.npmjs.org/@babel/template/-/template-7.0.0-beta.44.tgz",
|
||||
"integrity": "sha512-w750Sloq0UNifLx1rUqwfbnC6uSUk0mfwwgGRfdLiaUzfAOiH0tHJE6ILQIUi3KYkjiCDTskoIsnfqZvWLBDng==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "7.0.0-beta.44",
|
||||
"@babel/types": "7.0.0-beta.44",
|
||||
"babylon": "7.0.0-beta.44",
|
||||
"lodash": "^4.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"babylon": {
|
||||
"version": "7.0.0-beta.44",
|
||||
"resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.44.tgz",
|
||||
"integrity": "sha512-5Hlm13BJVAioCHpImtFqNOF2H3ieTOHd0fmFGMxOJ9jgeFqeAwsv3u5P5cR7CSeFrkgHsT19DgFJkHV0/Mcd8g==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"@babel/traverse": {
|
||||
"version": "7.0.0-beta.44",
|
||||
"resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.0.0-beta.44.tgz",
|
||||
"integrity": "sha512-UHuDz8ukQkJCDASKHf+oDt3FVUzFd+QYfuBIsiNu/4+/ix6pP/C+uQZJ6K1oEfbCMv/IKWbgDEh7fcsnIE5AtA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "7.0.0-beta.44",
|
||||
"@babel/generator": "7.0.0-beta.44",
|
||||
"@babel/helper-function-name": "7.0.0-beta.44",
|
||||
"@babel/helper-split-export-declaration": "7.0.0-beta.44",
|
||||
"@babel/types": "7.0.0-beta.44",
|
||||
"babylon": "7.0.0-beta.44",
|
||||
"debug": "^3.1.0",
|
||||
"globals": "^11.1.0",
|
||||
"invariant": "^2.2.0",
|
||||
"lodash": "^4.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"babylon": {
|
||||
"version": "7.0.0-beta.44",
|
||||
"resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.44.tgz",
|
||||
"integrity": "sha512-5Hlm13BJVAioCHpImtFqNOF2H3ieTOHd0fmFGMxOJ9jgeFqeAwsv3u5P5cR7CSeFrkgHsT19DgFJkHV0/Mcd8g==",
|
||||
"dev": true
|
||||
},
|
||||
"debug": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||
"integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"globals": {
|
||||
"version": "11.7.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-11.7.0.tgz",
|
||||
"integrity": "sha512-K8BNSPySfeShBQXsahYB/AbbWruVOTyVpgoIDnl8odPpeSfP2J5QO2oLFFdl2j7GfDCtZj2bMKar2T49itTPCg==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"@babel/types": {
|
||||
"version": "7.0.0-beta.44",
|
||||
"resolved": "https://registry.npmjs.org/@babel/types/-/types-7.0.0-beta.44.tgz",
|
||||
"integrity": "sha512-5eTV4WRmqbaFM3v9gHAIljEQJU4Ssc6fxL61JN+Oe2ga/BwyjzjamwkCVVAQjHGuAX8i0BWo42dshL8eO5KfLQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"esutils": "^2.0.2",
|
||||
"lodash": "^4.2.0",
|
||||
"to-fast-properties": "^2.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"to-fast-properties": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz",
|
||||
"integrity": "sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4=",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"@mrmlnc/readdir-enhanced": {
|
||||
"version": "2.2.1",
|
||||
"resolved": "https://registry.npmjs.org/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz",
|
||||
@ -294,20 +444,12 @@
|
||||
}
|
||||
},
|
||||
"acorn-jsx": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-3.0.1.tgz",
|
||||
"integrity": "sha1-r9+UiPsezvyDSPb7IvRk4ypYs2s=",
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-4.1.1.tgz",
|
||||
"integrity": "sha512-JY+iV6r+cO21KtntVvFkD+iqjtdpRUpGqKWgfkCdZq1R+kbreEl8EcdcJR4SmiIgsIQT33s6QzheQ9a275Q8xw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"acorn": "^3.0.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-3.3.0.tgz",
|
||||
"integrity": "sha1-ReN/s56No/JbruP/U2niu18iAXo=",
|
||||
"dev": true
|
||||
}
|
||||
"acorn": "^5.0.3"
|
||||
}
|
||||
},
|
||||
"ajv": {
|
||||
@ -586,6 +728,28 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"babel-eslint": {
|
||||
"version": "8.2.5",
|
||||
"resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-8.2.5.tgz",
|
||||
"integrity": "sha512-TcdEGCHHquOPQOlH6Fe6MLwPWWWJLdeKhcGoLfOTShETpoH8XYWhjWJw38KCKaTca7c/EdxLolnbakixKxnXDg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@babel/code-frame": "7.0.0-beta.44",
|
||||
"@babel/traverse": "7.0.0-beta.44",
|
||||
"@babel/types": "7.0.0-beta.44",
|
||||
"babylon": "7.0.0-beta.44",
|
||||
"eslint-scope": "~3.7.1",
|
||||
"eslint-visitor-keys": "^1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"babylon": {
|
||||
"version": "7.0.0-beta.44",
|
||||
"resolved": "https://registry.npmjs.org/babylon/-/babylon-7.0.0-beta.44.tgz",
|
||||
"integrity": "sha512-5Hlm13BJVAioCHpImtFqNOF2H3ieTOHd0fmFGMxOJ9jgeFqeAwsv3u5P5cR7CSeFrkgHsT19DgFJkHV0/Mcd8g==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"babel-generator": {
|
||||
"version": "6.26.1",
|
||||
"resolved": "https://registry.npmjs.org/babel-generator/-/babel-generator-6.26.1.tgz",
|
||||
@ -1920,12 +2084,6 @@
|
||||
"readable-stream": "^2.3.5"
|
||||
}
|
||||
},
|
||||
"co": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
|
||||
"integrity": "sha1-bqa989hTrlTMuOR7+gvz+QMfsYQ=",
|
||||
"dev": true
|
||||
},
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
|
||||
@ -2193,6 +2351,16 @@
|
||||
"integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=",
|
||||
"dev": true
|
||||
},
|
||||
"define-properties": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.2.tgz",
|
||||
"integrity": "sha1-g6c/L+pWmJj7c3GTyPhzyvbUXJQ=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"foreach": "^2.0.5",
|
||||
"object-keys": "^1.0.8"
|
||||
}
|
||||
},
|
||||
"define-property": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz",
|
||||
@ -2449,6 +2617,30 @@
|
||||
"is-arrayish": "^0.2.1"
|
||||
}
|
||||
},
|
||||
"es-abstract": {
|
||||
"version": "1.12.0",
|
||||
"resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.12.0.tgz",
|
||||
"integrity": "sha512-C8Fx/0jFmV5IPoMOFPA9P9G5NtqW+4cOPit3MIuvR2t7Ag2K15EJTpxnHAYTzL+aYQJIESYeXZmDBfOBE1HcpA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"es-to-primitive": "^1.1.1",
|
||||
"function-bind": "^1.1.1",
|
||||
"has": "^1.0.1",
|
||||
"is-callable": "^1.1.3",
|
||||
"is-regex": "^1.0.4"
|
||||
}
|
||||
},
|
||||
"es-to-primitive": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.1.1.tgz",
|
||||
"integrity": "sha1-RTVSSKiJeQNLZ5Lhm7gfK3l13Q0=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"is-callable": "^1.1.1",
|
||||
"is-date-object": "^1.0.1",
|
||||
"is-symbol": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"escape-string-regexp": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz",
|
||||
@ -2456,74 +2648,51 @@
|
||||
"dev": true
|
||||
},
|
||||
"eslint": {
|
||||
"version": "4.19.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-4.19.1.tgz",
|
||||
"integrity": "sha512-bT3/1x1EbZB7phzYu7vCr1v3ONuzDtX8WjuM9c0iYxe+cq+pwcKEoQjl7zd3RpC6YOLgnSy3cTN58M2jcoPDIQ==",
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-5.0.1.tgz",
|
||||
"integrity": "sha512-D5nG2rErquLUstgUaxJlWB5+gu+U/3VDY0fk/Iuq8y9CUFy/7Y6oF4N2cR1tV8knzQvciIbfqfohd359xTLIKQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ajv": "^5.3.0",
|
||||
"babel-code-frame": "^6.22.0",
|
||||
"ajv": "^6.5.0",
|
||||
"babel-code-frame": "^6.26.0",
|
||||
"chalk": "^2.1.0",
|
||||
"concat-stream": "^1.6.0",
|
||||
"cross-spawn": "^5.1.0",
|
||||
"cross-spawn": "^6.0.5",
|
||||
"debug": "^3.1.0",
|
||||
"doctrine": "^2.1.0",
|
||||
"eslint-scope": "^3.7.1",
|
||||
"eslint-scope": "^4.0.0",
|
||||
"eslint-visitor-keys": "^1.0.0",
|
||||
"espree": "^3.5.4",
|
||||
"esquery": "^1.0.0",
|
||||
"espree": "^4.0.0",
|
||||
"esquery": "^1.0.1",
|
||||
"esutils": "^2.0.2",
|
||||
"file-entry-cache": "^2.0.0",
|
||||
"functional-red-black-tree": "^1.0.1",
|
||||
"glob": "^7.1.2",
|
||||
"globals": "^11.0.1",
|
||||
"globals": "^11.5.0",
|
||||
"ignore": "^3.3.3",
|
||||
"imurmurhash": "^0.1.4",
|
||||
"inquirer": "^3.0.6",
|
||||
"is-resolvable": "^1.0.0",
|
||||
"js-yaml": "^3.9.1",
|
||||
"inquirer": "^5.2.0",
|
||||
"is-resolvable": "^1.1.0",
|
||||
"js-yaml": "^3.11.0",
|
||||
"json-stable-stringify-without-jsonify": "^1.0.1",
|
||||
"levn": "^0.3.0",
|
||||
"lodash": "^4.17.4",
|
||||
"minimatch": "^3.0.2",
|
||||
"lodash": "^4.17.5",
|
||||
"minimatch": "^3.0.4",
|
||||
"mkdirp": "^0.5.1",
|
||||
"natural-compare": "^1.4.0",
|
||||
"optionator": "^0.8.2",
|
||||
"path-is-inside": "^1.0.2",
|
||||
"pluralize": "^7.0.0",
|
||||
"progress": "^2.0.0",
|
||||
"regexpp": "^1.0.1",
|
||||
"regexpp": "^1.1.0",
|
||||
"require-uncached": "^1.0.3",
|
||||
"semver": "^5.3.0",
|
||||
"semver": "^5.5.0",
|
||||
"string.prototype.matchall": "^2.0.0",
|
||||
"strip-ansi": "^4.0.0",
|
||||
"strip-json-comments": "~2.0.1",
|
||||
"table": "4.0.2",
|
||||
"text-table": "~0.2.0"
|
||||
"strip-json-comments": "^2.0.1",
|
||||
"table": "^4.0.3",
|
||||
"text-table": "^0.2.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"ajv": {
|
||||
"version": "5.5.2",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
|
||||
"integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"co": "^4.6.0",
|
||||
"fast-deep-equal": "^1.0.0",
|
||||
"fast-json-stable-stringify": "^2.0.0",
|
||||
"json-schema-traverse": "^0.3.0"
|
||||
}
|
||||
},
|
||||
"cross-spawn": {
|
||||
"version": "5.1.0",
|
||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz",
|
||||
"integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"lru-cache": "^4.0.1",
|
||||
"shebang-command": "^1.2.0",
|
||||
"which": "^1.2.9"
|
||||
}
|
||||
},
|
||||
"debug": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz",
|
||||
@ -2533,39 +2702,21 @@
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"fast-deep-equal": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
|
||||
"integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=",
|
||||
"dev": true
|
||||
},
|
||||
"globals": {
|
||||
"version": "11.5.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-11.5.0.tgz",
|
||||
"integrity": "sha512-hYyf+kI8dm3nORsiiXUQigOU62hDLfJ9G01uyGMxhc6BKsircrUhC4uJPQPUSuq2GrTmiiEt7ewxlMdBewfmKQ==",
|
||||
"dev": true
|
||||
},
|
||||
"inquirer": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/inquirer/-/inquirer-3.3.0.tgz",
|
||||
"integrity": "sha512-h+xtnyk4EwKvFWHrUYsWErEVR+igKtLdchu+o0Z1RL7VU/jVMFbYir2bp6bAj8efFNxWqHX0dIss6fJQ+/+qeQ==",
|
||||
"eslint-scope": {
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.0.tgz",
|
||||
"integrity": "sha512-1G6UTDi7Jc1ELFwnR58HV4fK9OQK4S6N985f166xqXxpjU6plxFISJa2Ba9KCQuFa8RCnj/lSFJbHo7UFDBnUA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ansi-escapes": "^3.0.0",
|
||||
"chalk": "^2.0.0",
|
||||
"cli-cursor": "^2.1.0",
|
||||
"cli-width": "^2.0.0",
|
||||
"external-editor": "^2.0.4",
|
||||
"figures": "^2.0.0",
|
||||
"lodash": "^4.3.0",
|
||||
"mute-stream": "0.0.7",
|
||||
"run-async": "^2.2.0",
|
||||
"rx-lite": "^4.0.8",
|
||||
"rx-lite-aggregates": "^4.0.8",
|
||||
"string-width": "^2.1.0",
|
||||
"strip-ansi": "^4.0.0",
|
||||
"through": "^2.3.6"
|
||||
"esrecurse": "^4.1.0",
|
||||
"estraverse": "^4.1.1"
|
||||
}
|
||||
},
|
||||
"globals": {
|
||||
"version": "11.7.0",
|
||||
"resolved": "https://registry.npmjs.org/globals/-/globals-11.7.0.tgz",
|
||||
"integrity": "sha512-K8BNSPySfeShBQXsahYB/AbbWruVOTyVpgoIDnl8odPpeSfP2J5QO2oLFFdl2j7GfDCtZj2bMKar2T49itTPCg==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -2586,13 +2737,13 @@
|
||||
"dev": true
|
||||
},
|
||||
"espree": {
|
||||
"version": "3.5.4",
|
||||
"resolved": "https://registry.npmjs.org/espree/-/espree-3.5.4.tgz",
|
||||
"integrity": "sha512-yAcIQxtmMiB/jL32dzEp2enBeidsB7xWPLNiw3IIkpVds1P+h7qF9YwJq1yUNzp2OKXgAprs4F61ih66UsoD1A==",
|
||||
"version": "4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/espree/-/espree-4.0.0.tgz",
|
||||
"integrity": "sha512-kapdTCt1bjmspxStVKX6huolXVV5ZfyZguY1lcfhVVZstce3bqxH9mcLzNn3/mlgW6wQ732+0fuG9v7h0ZQoKg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"acorn": "^5.5.0",
|
||||
"acorn-jsx": "^3.0.0"
|
||||
"acorn": "^5.6.0",
|
||||
"acorn-jsx": "^4.1.1"
|
||||
}
|
||||
},
|
||||
"esprima": {
|
||||
@ -3025,6 +3176,12 @@
|
||||
"for-in": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"foreach": {
|
||||
"version": "2.0.5",
|
||||
"resolved": "https://registry.npmjs.org/foreach/-/foreach-2.0.5.tgz",
|
||||
"integrity": "sha1-C+4AUBiusmDQo6865ljdATbsG5k=",
|
||||
"dev": true
|
||||
},
|
||||
"fragment-cache": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz",
|
||||
@ -3082,7 +3239,8 @@
|
||||
"ansi-regex": {
|
||||
"version": "2.1.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"aproba": {
|
||||
"version": "1.2.0",
|
||||
@ -3103,12 +3261,14 @@
|
||||
"balanced-match": {
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"brace-expansion": {
|
||||
"version": "1.1.11",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"balanced-match": "^1.0.0",
|
||||
"concat-map": "0.0.1"
|
||||
@ -3123,17 +3283,20 @@
|
||||
"code-point-at": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"concat-map": {
|
||||
"version": "0.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"console-control-strings": {
|
||||
"version": "1.1.0",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"core-util-is": {
|
||||
"version": "1.0.2",
|
||||
@ -3250,7 +3413,8 @@
|
||||
"inherits": {
|
||||
"version": "2.0.3",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"ini": {
|
||||
"version": "1.3.5",
|
||||
@ -3262,6 +3426,7 @@
|
||||
"version": "1.0.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
@ -3276,6 +3441,7 @@
|
||||
"version": "3.0.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"brace-expansion": "^1.1.7"
|
||||
}
|
||||
@ -3283,12 +3449,14 @@
|
||||
"minimist": {
|
||||
"version": "0.0.8",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"minipass": {
|
||||
"version": "2.2.4",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"safe-buffer": "^5.1.1",
|
||||
"yallist": "^3.0.0"
|
||||
@ -3307,6 +3475,7 @@
|
||||
"version": "0.5.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"minimist": "0.0.8"
|
||||
}
|
||||
@ -3387,7 +3556,8 @@
|
||||
"number-is-nan": {
|
||||
"version": "1.0.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"object-assign": {
|
||||
"version": "4.1.1",
|
||||
@ -3399,6 +3569,7 @@
|
||||
"version": "1.4.0",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"wrappy": "1"
|
||||
}
|
||||
@ -3484,7 +3655,8 @@
|
||||
"safe-buffer": {
|
||||
"version": "5.1.1",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
@ -3520,6 +3692,7 @@
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"code-point-at": "^1.0.0",
|
||||
"is-fullwidth-code-point": "^1.0.0",
|
||||
@ -3539,6 +3712,7 @@
|
||||
"version": "3.0.1",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true,
|
||||
"requires": {
|
||||
"ansi-regex": "^2.0.0"
|
||||
}
|
||||
@ -3582,14 +3756,22 @@
|
||||
"wrappy": {
|
||||
"version": "1.0.2",
|
||||
"bundled": true,
|
||||
"dev": true
|
||||
"dev": true,
|
||||
"optional": true
|
||||
},
|
||||
"yallist": {
|
||||
"version": "3.0.2",
|
||||
"bundled": true,
|
||||
"dev": true,
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"function-bind": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
|
||||
"integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"functional-red-black-tree": {
|
||||
"version": "1.0.1",
|
||||
@ -3877,6 +4059,15 @@
|
||||
"lodash": "^4.17.2"
|
||||
}
|
||||
},
|
||||
"has": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
|
||||
"integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"function-bind": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"has-ansi": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-2.0.0.tgz",
|
||||
@ -3912,6 +4103,12 @@
|
||||
"integrity": "sha512-3ToOva++HaW+eCpgqZrCfN51IPB+7bJNVT6CUATzueB5Heb8o6Nam0V3HG5dlDvZU1Gn5QLcbahiKw/XVk5JJw==",
|
||||
"dev": true
|
||||
},
|
||||
"has-symbols": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz",
|
||||
"integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=",
|
||||
"dev": true
|
||||
},
|
||||
"has-to-string-tag-x": {
|
||||
"version": "1.4.1",
|
||||
"resolved": "https://registry.npmjs.org/has-to-string-tag-x/-/has-to-string-tag-x-1.4.1.tgz",
|
||||
@ -4203,6 +4400,12 @@
|
||||
"builtin-modules": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"is-callable": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz",
|
||||
"integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==",
|
||||
"dev": true
|
||||
},
|
||||
"is-data-descriptor": {
|
||||
"version": "0.1.4",
|
||||
"resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz",
|
||||
@ -4223,6 +4426,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"is-date-object": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz",
|
||||
"integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=",
|
||||
"dev": true
|
||||
},
|
||||
"is-descriptor": {
|
||||
"version": "0.1.6",
|
||||
"resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz",
|
||||
@ -4410,6 +4619,15 @@
|
||||
"integrity": "sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=",
|
||||
"dev": true
|
||||
},
|
||||
"is-regex": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz",
|
||||
"integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"has": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"is-resolvable": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-resolvable/-/is-resolvable-1.1.0.tgz",
|
||||
@ -4437,6 +4655,12 @@
|
||||
"integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=",
|
||||
"dev": true
|
||||
},
|
||||
"is-symbol": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.1.tgz",
|
||||
"integrity": "sha1-PMWfAAJRlLarLjjbrmaJJWtmBXI=",
|
||||
"dev": true
|
||||
},
|
||||
"is-utf8": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/is-utf8/-/is-utf8-0.2.1.tgz",
|
||||
@ -5608,6 +5832,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"object-keys": {
|
||||
"version": "1.0.12",
|
||||
"resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.0.12.tgz",
|
||||
"integrity": "sha512-FTMyFUm2wBcGHnH2eXmz7tC6IwlqQZ6mVZ+6dm6vZ4IQIHjs6FdNsQBuKGPuUUUY6NfJw2PshC08Tn6LzLDOag==",
|
||||
"dev": true
|
||||
},
|
||||
"object-visit": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz",
|
||||
@ -6343,6 +6573,15 @@
|
||||
"safe-regex": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"regexp.prototype.flags": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.2.0.tgz",
|
||||
"integrity": "sha512-ztaw4M1VqgMwl9HlPpOuiYgItcHlunW0He2fE6eNfT6E/CF2FtYi9ofOYe4mKntstYk0Fyh/rDRBdS3AnxjlrA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"define-properties": "^1.1.2"
|
||||
}
|
||||
},
|
||||
"regexpp": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/regexpp/-/regexpp-1.1.0.tgz",
|
||||
@ -6540,21 +6779,6 @@
|
||||
"aproba": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"rx-lite": {
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/rx-lite/-/rx-lite-4.0.8.tgz",
|
||||
"integrity": "sha1-Cx4Rr4vESDbwSmQH6S2kJGe3lEQ=",
|
||||
"dev": true
|
||||
},
|
||||
"rx-lite-aggregates": {
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://registry.npmjs.org/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz",
|
||||
"integrity": "sha1-dTuHqJoRyVRnxKwWJsTvxOBcZ74=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"rx-lite": "*"
|
||||
}
|
||||
},
|
||||
"rxjs": {
|
||||
"version": "5.5.11",
|
||||
"resolved": "https://registry.npmjs.org/rxjs/-/rxjs-5.5.11.tgz",
|
||||
@ -7008,6 +7232,19 @@
|
||||
"strip-ansi": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"string.prototype.matchall": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/string.prototype.matchall/-/string.prototype.matchall-2.0.0.tgz",
|
||||
"integrity": "sha512-WoZ+B2ypng1dp4iFLF2kmZlwwlE19gmjgKuhL1FJfDgCREWb3ye3SDVHSzLH6bxfnvYmkCxbzkmWcQZHA4P//Q==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"define-properties": "^1.1.2",
|
||||
"es-abstract": "^1.10.0",
|
||||
"function-bind": "^1.1.1",
|
||||
"has-symbols": "^1.0.0",
|
||||
"regexp.prototype.flags": "^1.2.0"
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
@ -7073,43 +7310,19 @@
|
||||
"dev": true
|
||||
},
|
||||
"table": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/table/-/table-4.0.2.tgz",
|
||||
"integrity": "sha512-UUkEAPdSGxtRpiV9ozJ5cMTtYiqz7Ni1OGqLXRCynrvzdtR1p+cfOWe2RJLwvUG8hNanaSRjecIqwOjqeatDsA==",
|
||||
"version": "4.0.3",
|
||||
"resolved": "https://registry.npmjs.org/table/-/table-4.0.3.tgz",
|
||||
"integrity": "sha512-S7rnFITmBH1EnyKcvxBh1LjYeQMmnZtCXSEbHcH6S0NoKit24ZuFO/T1vDcLdYsLQkM188PVVhQmzKIuThNkKg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"ajv": "^5.2.3",
|
||||
"ajv-keywords": "^2.1.0",
|
||||
"ajv": "^6.0.1",
|
||||
"ajv-keywords": "^3.0.0",
|
||||
"chalk": "^2.1.0",
|
||||
"lodash": "^4.17.4",
|
||||
"slice-ansi": "1.0.0",
|
||||
"string-width": "^2.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"ajv": {
|
||||
"version": "5.5.2",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-5.5.2.tgz",
|
||||
"integrity": "sha1-c7Xuyj+rZT49P5Qis0GtQiBdyWU=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"co": "^4.6.0",
|
||||
"fast-deep-equal": "^1.0.0",
|
||||
"fast-json-stable-stringify": "^2.0.0",
|
||||
"json-schema-traverse": "^0.3.0"
|
||||
}
|
||||
},
|
||||
"ajv-keywords": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-2.1.1.tgz",
|
||||
"integrity": "sha1-YXmX/F9gV2iUxDX5QNgZ4TW4B2I=",
|
||||
"dev": true
|
||||
},
|
||||
"fast-deep-equal": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-1.1.0.tgz",
|
||||
"integrity": "sha1-wFNHeBfIa1HaqFPIHgWbcz0CNhQ=",
|
||||
"dev": true
|
||||
},
|
||||
"slice-ansi": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/slice-ansi/-/slice-ansi-1.0.0.tgz",
|
||||
|
@ -9,6 +9,7 @@
|
||||
"typescript": "^2.7.2",
|
||||
"webpack": "^4.11.1",
|
||||
"webpack-cli": "^2.0.10",
|
||||
"eslint": "^4.19.1"
|
||||
"babel-eslint": "^8.2.5",
|
||||
"eslint": "^5.0.1"
|
||||
}
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ fn works() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -135,10 +135,10 @@ fn works() {
|
||||
|
||||
assert.strictEqual(typeof(wasm.mk_symbol()), 'symbol');
|
||||
assert.strictEqual(typeof(wasm.mk_symbol2('a')), 'symbol');
|
||||
assert.strictEqual((Symbol as any).keyFor(wasm.mk_symbol()), undefined);
|
||||
assert.strictEqual((Symbol as any).keyFor(wasm.mk_symbol2('b')), undefined);
|
||||
assert.strictEqual(Symbol.keyFor(wasm.mk_symbol()), undefined);
|
||||
assert.strictEqual(Symbol.keyFor(wasm.mk_symbol2('b')), undefined);
|
||||
|
||||
wasm.assert_symbols((Symbol as any)(), 'a');
|
||||
wasm.assert_symbols(Symbol(), 'a');
|
||||
wasm.acquire_string('foo', null)
|
||||
assert.strictEqual(wasm.acquire_string2(''), '');
|
||||
assert.strictEqual(wasm.acquire_string2('a'), 'a');
|
||||
@ -172,7 +172,7 @@ fn eq_works() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
@ -40,7 +40,7 @@ fn simple() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import { Foo } from "./out";
|
||||
@ -115,7 +115,7 @@ fn strings() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import { Foo } from "./out";
|
||||
@ -198,12 +198,6 @@ fn exceptions() {
|
||||
};
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.d.ts",
|
||||
r#"
|
||||
export function test(): void;
|
||||
"#,
|
||||
)
|
||||
.test();
|
||||
}
|
||||
|
||||
@ -247,7 +241,7 @@ fn pass_one_to_another() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { A, B } from "./out";
|
||||
|
||||
@ -297,12 +291,12 @@ fn pass_into_js() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run, Foo } from "./out";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function take_foo(foo: Foo) {
|
||||
export function take_foo(foo) {
|
||||
assert.strictEqual(foo.inner(), 13);
|
||||
foo.free();
|
||||
assert.throws(() => foo.free(), /null pointer passed to rust/);
|
||||
@ -353,7 +347,7 @@ fn issue_27() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { context } from "./out";
|
||||
|
||||
@ -399,13 +393,13 @@ fn pass_into_js_as_js_class() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run, Foo } from "./out";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function take_foo(foo: any) {
|
||||
assert(foo instanceof Foo);
|
||||
export function take_foo(foo) {
|
||||
assert.ok(foo instanceof Foo);
|
||||
assert.strictEqual(foo.inner(), 13);
|
||||
foo.free();
|
||||
}
|
||||
@ -472,7 +466,7 @@ fn constructors() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import { Foo, Bar, cross_item_construction } from "./out";
|
||||
@ -525,7 +519,7 @@ fn empty_structs() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { Other } from "./out";
|
||||
|
||||
@ -568,7 +562,7 @@ fn public_fields() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { Foo } from "./out";
|
||||
import * as assert from "assert";
|
||||
@ -622,7 +616,7 @@ fn using_self() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { Foo } from "./out";
|
||||
|
||||
@ -663,7 +657,7 @@ fn readonly_fields() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { Foo } from "./out";
|
||||
import * as assert from "assert";
|
||||
@ -671,7 +665,7 @@ fn readonly_fields() {
|
||||
export function test() {
|
||||
const a = Foo.new();
|
||||
assert.strictEqual(a.a, 0);
|
||||
assert.throws(() => (a as any).a = 3, /has only a getter/);
|
||||
assert.throws(() => a.a = 3, /has only a getter/);
|
||||
a.free();
|
||||
}
|
||||
"#,
|
||||
@ -704,7 +698,7 @@ fn double_consume() {
|
||||
}
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import { Foo } from "./out";
|
||||
|
||||
|
@ -30,15 +30,15 @@ fn works() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
export function call(a: any) {
|
||||
export function call(a) {
|
||||
a();
|
||||
}
|
||||
|
||||
export function thread(a: any) {
|
||||
export function thread(a) {
|
||||
return a(2);
|
||||
}
|
||||
|
||||
@ -77,13 +77,13 @@ fn cannot_reuse() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
let CACHE: any = null;
|
||||
let CACHE = null;
|
||||
|
||||
export function call(a: any) {
|
||||
export function call(a) {
|
||||
CACHE = a;
|
||||
}
|
||||
|
||||
@ -142,15 +142,15 @@ fn long_lived() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
export function call1(a: any) {
|
||||
export function call1(a) {
|
||||
a();
|
||||
}
|
||||
|
||||
export function call2(a: any) {
|
||||
export function call2(a) {
|
||||
return a(2);
|
||||
}
|
||||
|
||||
@ -242,18 +242,18 @@ fn many_arity() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
export function call1(a: any) { a() }
|
||||
export function call2(a: any) { a(1) }
|
||||
export function call3(a: any) { a(1, 2) }
|
||||
export function call4(a: any) { a(1, 2, 3) }
|
||||
export function call5(a: any) { a(1, 2, 3, 4) }
|
||||
export function call6(a: any) { a(1, 2, 3, 4, 5) }
|
||||
export function call7(a: any) { a(1, 2, 3, 4, 5, 6) }
|
||||
export function call8(a: any) { a(1, 2, 3, 4, 5, 6, 7) }
|
||||
export function call1(a) { a() }
|
||||
export function call2(a) { a(1) }
|
||||
export function call3(a) { a(1, 2) }
|
||||
export function call4(a) { a(1, 2, 3) }
|
||||
export function call5(a) { a(1, 2, 3, 4) }
|
||||
export function call6(a) { a(1, 2, 3, 4, 5) }
|
||||
export function call7(a) { a(1, 2, 3, 4, 5, 6) }
|
||||
export function call8(a) { a(1, 2, 3, 4, 5, 6, 7) }
|
||||
|
||||
export function test() {
|
||||
run();
|
||||
@ -299,13 +299,13 @@ fn long_lived_dropping() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
let CACHE: any = null;
|
||||
let CACHE = null;
|
||||
|
||||
export function cache(a: any) { CACHE = a; }
|
||||
export function cache(a) { CACHE = a; }
|
||||
export function call() { CACHE() }
|
||||
|
||||
export function test() {
|
||||
@ -346,13 +346,13 @@ fn long_fnmut_recursive() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
let CACHE: any = null;
|
||||
let CACHE = null;
|
||||
|
||||
export function cache(a: any) { CACHE = a; }
|
||||
export function cache(a) { CACHE = a; }
|
||||
export function call() { CACHE() }
|
||||
|
||||
export function test() {
|
||||
@ -397,15 +397,15 @@ fn fnmut() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
export function call(a: any) {
|
||||
export function call(a) {
|
||||
a();
|
||||
}
|
||||
|
||||
export function thread(a: any) {
|
||||
export function thread(a) {
|
||||
return a(2);
|
||||
}
|
||||
|
||||
@ -455,18 +455,18 @@ fn fnmut_bad() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
let F: any = null;
|
||||
let F = null;
|
||||
|
||||
export function call(a: any) {
|
||||
export function call(a) {
|
||||
F = a;
|
||||
a();
|
||||
}
|
||||
|
||||
export function again(x: boolean) {
|
||||
export function again(x) {
|
||||
if (x) F();
|
||||
}
|
||||
|
||||
@ -507,11 +507,11 @@ fn string_arguments() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
export function call(a: any) {
|
||||
export function call(a) {
|
||||
a("foo")
|
||||
}
|
||||
|
||||
@ -554,12 +554,12 @@ fn string_ret() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function call(a: any) {
|
||||
export function call(a) {
|
||||
const s = a("foo");
|
||||
assert.strictEqual(s, "foobar");
|
||||
}
|
||||
|
@ -38,12 +38,12 @@ fn works() {
|
||||
"#,
|
||||
);
|
||||
|
||||
let (root, target) = p.cargo_build();
|
||||
p.gen_bindings(&root, &target);
|
||||
p.gen_bindings();
|
||||
let js = p.read_js();
|
||||
let comments = extract_doc_comments(&js);
|
||||
assert!(comments.iter().all(|c| c == "This comment should exist"));
|
||||
}
|
||||
|
||||
/// Pull out all lines in a js string that start with
|
||||
/// '* ', all other lines will either be comment start, comment
|
||||
/// end or actual js lines.
|
||||
|
@ -66,7 +66,7 @@ fn dependencies_work() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -84,7 +84,7 @@ fn dependencies_work() {
|
||||
|
||||
const z = wasm.takes_own_dep_ty(foo);
|
||||
assert.strictEqual(z, y);
|
||||
assert.strictEqual((foo as any).ptr, 0);
|
||||
assert.strictEqual(foo.ptr, 0);
|
||||
}
|
||||
"#,
|
||||
)
|
||||
|
@ -30,7 +30,7 @@ fn c_style_enum() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -84,7 +84,7 @@ fn c_style_enum_with_custom_values() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
@ -32,7 +32,7 @@ fn simple() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out";
|
||||
import * as assert from "assert";
|
||||
@ -71,7 +71,7 @@ fn import_class() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { baz } from "./out";
|
||||
import { called } from "./another";
|
||||
@ -84,7 +84,7 @@ fn import_class() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"another.ts",
|
||||
"another.js",
|
||||
r#"
|
||||
export let called = false;
|
||||
|
||||
@ -133,7 +133,7 @@ fn construct() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
import { called } from "./another";
|
||||
@ -146,15 +146,13 @@ fn construct() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"another.ts",
|
||||
"another.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
|
||||
export let called = false;
|
||||
|
||||
export class Foo {
|
||||
private internal_string: string = '';
|
||||
|
||||
static create() {
|
||||
const ret = new Foo();
|
||||
ret.internal_string = 'this';
|
||||
@ -165,15 +163,17 @@ fn construct() {
|
||||
return this.internal_string;
|
||||
}
|
||||
|
||||
append_to_internal_string(s: string) {
|
||||
append_to_internal_string(s) {
|
||||
this.internal_string += s;
|
||||
}
|
||||
|
||||
assert_internal_string(s: string) {
|
||||
assert_internal_string(s) {
|
||||
assert.strictEqual(this.internal_string, s);
|
||||
called = true;
|
||||
}
|
||||
}
|
||||
|
||||
Foo.internal_string = '';
|
||||
"#,
|
||||
)
|
||||
.test();
|
||||
@ -208,7 +208,7 @@ fn new_constructors() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
@ -218,10 +218,11 @@ fn new_constructors() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"another.ts",
|
||||
"another.js",
|
||||
r#"
|
||||
export class Foo {
|
||||
constructor(private field: number) {
|
||||
constructor(field) {
|
||||
this.field = field;
|
||||
}
|
||||
|
||||
get() {
|
||||
@ -271,7 +272,7 @@ fn switch_methods() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { a, b } from "./out";
|
||||
import { Foo, called } from "./another";
|
||||
@ -300,7 +301,7 @@ fn switch_methods() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"another.ts",
|
||||
"another.js",
|
||||
r#"
|
||||
export let called = { a: false };
|
||||
|
||||
@ -357,7 +358,7 @@ fn properties() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
@ -367,10 +368,10 @@ fn properties() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"another.ts",
|
||||
"another.js",
|
||||
r#"
|
||||
export class Foo {
|
||||
constructor(private num: number) {
|
||||
constructor() {
|
||||
this.num = 1;
|
||||
}
|
||||
|
||||
@ -423,7 +424,7 @@ fn rename_setter_getter() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
@ -433,10 +434,10 @@ fn rename_setter_getter() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"another.ts",
|
||||
"another.js",
|
||||
r#"
|
||||
export class Foo {
|
||||
constructor(private num: number) {
|
||||
constructor() {
|
||||
this.num = 1;
|
||||
}
|
||||
|
||||
|
@ -42,30 +42,30 @@ fn simple() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out";
|
||||
import * as assert from "assert";
|
||||
|
||||
let ARG: string | null = null;
|
||||
let ANOTHER_ARG: number | null = null;
|
||||
let SYM = (Symbol as any)('a');
|
||||
let ARG = null;
|
||||
let ANOTHER_ARG = null;
|
||||
let SYM = Symbol('a');
|
||||
|
||||
export function foo(s: string): void {
|
||||
export function foo(s) {
|
||||
assert.strictEqual(ARG, null);
|
||||
assert.strictEqual(s, "foo");
|
||||
ARG = s;
|
||||
}
|
||||
export function another(s: number): number {
|
||||
export function another(s) {
|
||||
assert.strictEqual(ANOTHER_ARG, null);
|
||||
assert.strictEqual(s, 21);
|
||||
ANOTHER_ARG = s;
|
||||
return 35;
|
||||
}
|
||||
export function take_and_return_bool(s: boolean): boolean {
|
||||
export function take_and_return_bool(s) {
|
||||
return s;
|
||||
}
|
||||
export function return_object(): any {
|
||||
export function return_object() {
|
||||
return SYM;
|
||||
}
|
||||
|
||||
@ -111,7 +111,7 @@ fn unused() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -149,11 +149,11 @@ fn string_ret() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function foo(): string {
|
||||
export function foo() {
|
||||
return 'bar';
|
||||
}
|
||||
|
||||
@ -194,12 +194,12 @@ fn strings() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function foo(a: string): string {
|
||||
export function foo(a) {
|
||||
return a + 'b';
|
||||
}
|
||||
|
||||
@ -246,7 +246,7 @@ fn exceptions() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run, run2 } from "./out";
|
||||
import * as assert from "assert";
|
||||
@ -301,7 +301,7 @@ fn exn_caught() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
import * as assert from "assert";
|
||||
@ -344,7 +344,7 @@ fn free_imports() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
@ -381,7 +381,7 @@ fn import_a_field() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
@ -420,7 +420,7 @@ fn rename() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out";
|
||||
import * as assert from "assert";
|
||||
@ -443,6 +443,7 @@ fn rename() {
|
||||
#[test]
|
||||
fn versions() {
|
||||
project()
|
||||
.debug(false)
|
||||
.file(
|
||||
"src/lib.rs",
|
||||
r#"
|
||||
@ -466,10 +467,10 @@ fn versions() {
|
||||
.file(
|
||||
"test.js",
|
||||
r#"
|
||||
const fs = require("fs");
|
||||
const assert = require("assert");
|
||||
import * as fs from 'fs';
|
||||
import * as assert from 'assert';
|
||||
|
||||
exports.test = function() {
|
||||
export function test() {
|
||||
const bytes = fs.readFileSync('out_bg.wasm');
|
||||
const m = new WebAssembly.Module(bytes);
|
||||
const name = '__wasm_pack_unstable';
|
||||
@ -511,10 +512,10 @@ fn underscore_pattern() {
|
||||
foo(1);
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import { run } from "./out";
|
||||
|
||||
export function foo(_a: number) {
|
||||
export function foo(_a) {
|
||||
}
|
||||
|
||||
export function test() {
|
||||
@ -549,7 +550,7 @@ fn rust_keyword() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
@ -592,7 +593,7 @@ fn rust_keyword2() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run } from "./out";
|
||||
|
||||
@ -645,18 +646,18 @@ fn custom_type() {
|
||||
bad2();
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import { run, Foo, bad } from "./out";
|
||||
|
||||
let VAL: any = null;
|
||||
let VAL = null;
|
||||
|
||||
export function foo(f: Foo): Foo {
|
||||
export function foo(f) {
|
||||
VAL = f;
|
||||
return f;
|
||||
}
|
||||
|
||||
export function bad2(): number {
|
||||
export function bad2() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
@ -691,7 +692,7 @@ fn unused_imports_not_generated() {
|
||||
pub fn run() {
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import { run } from "./out";
|
||||
|
||||
export function test() {
|
||||
|
@ -22,7 +22,7 @@ fn filter() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -61,7 +61,7 @@ fn index_of() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -104,27 +104,27 @@ fn is_array() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
assert(wasm.is_array([]));
|
||||
assert(wasm.is_array([1]));
|
||||
assert(wasm.is_array(new Array()));
|
||||
assert(wasm.is_array(new Array('a', 'b', 'c', 'd')));
|
||||
assert(wasm.is_array(new Array(3)));
|
||||
assert(wasm.is_array(Array.prototype));
|
||||
assert.ok(wasm.is_array([]));
|
||||
assert.ok(wasm.is_array([1]));
|
||||
assert.ok(wasm.is_array(new Array()));
|
||||
assert.ok(wasm.is_array(new Array('a', 'b', 'c', 'd')));
|
||||
assert.ok(wasm.is_array(new Array(3)));
|
||||
assert.ok(wasm.is_array(Array.prototype));
|
||||
|
||||
assert(!wasm.is_array({}));
|
||||
assert(!wasm.is_array(null));
|
||||
assert(!wasm.is_array(undefined));
|
||||
assert(!wasm.is_array(17));
|
||||
assert(!wasm.is_array('Array'));
|
||||
assert(!wasm.is_array(true));
|
||||
assert(!wasm.is_array(false));
|
||||
assert(!wasm.is_array({ __proto__: Array.prototype }));
|
||||
assert.ok(!wasm.is_array({}));
|
||||
assert.ok(!wasm.is_array(null));
|
||||
assert.ok(!wasm.is_array(undefined));
|
||||
assert.ok(!wasm.is_array(17));
|
||||
assert.ok(!wasm.is_array('Array'));
|
||||
assert.ok(!wasm.is_array(true));
|
||||
assert.ok(!wasm.is_array(false));
|
||||
assert.ok(!wasm.is_array({ __proto__: Array.prototype }));
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -151,7 +151,7 @@ fn sort() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -183,7 +183,7 @@ fn some() {
|
||||
}
|
||||
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -218,7 +218,7 @@ fn last_index_of() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -262,7 +262,7 @@ fn join() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -299,7 +299,7 @@ fn slice() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -335,7 +335,7 @@ fn fill() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -368,7 +368,7 @@ fn copy_within() {
|
||||
}
|
||||
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -406,7 +406,7 @@ fn pop() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -442,7 +442,7 @@ fn push() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -478,7 +478,7 @@ fn reverse() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -514,7 +514,7 @@ fn shift() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -551,7 +551,7 @@ fn unshift() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -588,7 +588,7 @@ fn to_string() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -624,7 +624,7 @@ fn includes() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -665,7 +665,7 @@ fn concat() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -702,7 +702,7 @@ fn length() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -712,7 +712,7 @@ fn length() {
|
||||
let charactersLength = wasm.array_length(characters);
|
||||
assert.equal(charactersLength, 6);
|
||||
|
||||
var empty : number[] = [];
|
||||
var empty = [];
|
||||
let emptyLength = wasm.array_length(empty);
|
||||
assert.equal(emptyLength, 0);
|
||||
}
|
||||
@ -740,7 +740,7 @@ fn every() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -750,9 +750,9 @@ fn every() {
|
||||
const arrayOdd = [1, 3, 5, 7];
|
||||
const arrayMixed = [2, 3, 4, 5];
|
||||
|
||||
assert(wasm.array_every_number_is_even(arrayEven));
|
||||
assert(!wasm.array_every_number_is_even(arrayOdd));
|
||||
assert(!wasm.array_every_number_is_even(arrayMixed));
|
||||
assert.ok(wasm.array_every_number_is_even(arrayEven));
|
||||
assert.ok(!wasm.array_every_number_is_even(arrayOdd));
|
||||
assert.ok(!wasm.array_every_number_is_even(arrayMixed));
|
||||
}
|
||||
"#,
|
||||
)
|
||||
|
@ -17,7 +17,7 @@ fn new() {
|
||||
ArrayBuffer::new(42)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -44,7 +44,7 @@ fn is_view() {
|
||||
ArrayBuffer::is_view(value)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -70,7 +70,7 @@ fn slice() {
|
||||
arraybuffer.slice(begin)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -97,7 +97,7 @@ fn slice_with_end() {
|
||||
arraybuffer.slice_with_end(begin, end)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
|
@ -22,7 +22,7 @@ fn keys() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -60,7 +60,7 @@ fn entries() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
@ -21,7 +21,7 @@ fn new_undefined() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -53,7 +53,7 @@ fn new_truely() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
@ -21,7 +21,7 @@ fn get_day() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -55,7 +55,7 @@ fn get_full_year() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -91,7 +91,7 @@ fn new() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -119,7 +119,7 @@ fn now() {
|
||||
Date::now()
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -149,7 +149,7 @@ fn to_date_string() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -183,7 +183,7 @@ fn to_iso_string() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -217,7 +217,7 @@ fn to_json() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -248,7 +248,7 @@ fn to_locale_date_string() {
|
||||
this.to_locale_date_string(locale, options)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -280,7 +280,7 @@ fn to_locale_string() {
|
||||
this.to_locale_string(locale, options)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -313,7 +313,7 @@ fn to_locale_time_string() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -346,7 +346,7 @@ fn to_string() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -379,7 +379,7 @@ fn to_time_string() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -412,7 +412,7 @@ fn to_utc_string() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -441,7 +441,7 @@ fn utc() {
|
||||
Date::utc(2018f64, 6f64)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -471,7 +471,7 @@ fn value_of() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
@ -18,7 +18,7 @@ fn new() {
|
||||
Error::new(message)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -48,7 +48,7 @@ fn message() {
|
||||
this.message()
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -78,7 +78,7 @@ fn set_message() {
|
||||
this.set_message(message);
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -109,7 +109,7 @@ fn name() {
|
||||
this.name()
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -140,7 +140,7 @@ fn set_name() {
|
||||
this.set_name(name);
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -171,7 +171,7 @@ fn to_string() {
|
||||
this.to_string()
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -180,13 +180,13 @@ fn to_string() {
|
||||
|
||||
assert.equal(wasm.error_to_string(error), 'Error: error message 1');
|
||||
|
||||
(error.name as any) = undefined;
|
||||
error.name = undefined;
|
||||
assert.equal(wasm.error_to_string(error), 'Error: error message 1');
|
||||
|
||||
error.name = 'error_name_1';
|
||||
assert.equal(wasm.error_to_string(error), 'error_name_1: error message 1');
|
||||
|
||||
(error.message as any) = undefined;
|
||||
error.message = undefined;
|
||||
assert.equal(wasm.error_to_string(error), 'error_name_1');
|
||||
|
||||
error.name = 'error_name_2';
|
||||
|
@ -21,7 +21,7 @@ fn apply() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -57,7 +57,7 @@ fn bind() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -97,21 +97,21 @@ fn length() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
assert.equal(wasm.fn_length(() => {}), 0);
|
||||
assert.equal(wasm.fn_length((a: string) => console.log(a)), 1);
|
||||
assert.equal(wasm.fn_length((a: string, b: string) => console.log({ a, b })), 2);
|
||||
assert.equal(wasm.fn_length(a => console.log(a)), 1);
|
||||
assert.equal(wasm.fn_length((a, b) => console.log({ a, b })), 2);
|
||||
|
||||
function fn0() {}
|
||||
function fn1(a: string) {
|
||||
function fn1(a) {
|
||||
console.log(a);
|
||||
}
|
||||
function fn2(a: string, b: string) {
|
||||
function fn2(a, b) {
|
||||
console.log({ a, b });
|
||||
}
|
||||
|
||||
@ -143,7 +143,7 @@ fn name() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -190,17 +190,17 @@ fn to_string() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
function fn1(a: any, b: any) { return a + b }
|
||||
const fn2 = (a: number) => console.log(a);
|
||||
function fn1(a, b) { return a + b; }
|
||||
const fn2 = a => console.log(a);
|
||||
|
||||
assert.equal(wasm.get_source_code(fn1), 'function fn1(a, b) { return a + b; }');
|
||||
assert.equal(wasm.get_source_code(fn2), 'function (a) { return console.log(a); }');
|
||||
assert.equal(wasm.get_source_code(fn2), 'a => console.log(a)');
|
||||
}
|
||||
"#,
|
||||
)
|
||||
|
@ -21,7 +21,7 @@ fn return_() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -72,7 +72,7 @@ fn next() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -97,7 +97,7 @@ fn next() {
|
||||
yield 1;
|
||||
}
|
||||
|
||||
assert(wasm.next_throws_error(brokenGenerator(), undefined));
|
||||
assert.ok(wasm.next_throws_error(brokenGenerator(), undefined));
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -123,7 +123,7 @@ fn throw() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -137,7 +137,7 @@ fn throw() {
|
||||
const gen = generator();
|
||||
gen.next();
|
||||
|
||||
assert(wasm.gen_throws_error(gen, new Error('Something went wrong')));
|
||||
assert.ok(wasm.gen_throws_error(gen, new Error('Something went wrong')));
|
||||
assert.deepEqual(gen.next(), { value: undefined, done: true });
|
||||
}
|
||||
"#,
|
||||
|
@ -22,7 +22,7 @@ fn length() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -58,7 +58,7 @@ fn char_at() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -93,7 +93,7 @@ fn char_code_at() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -128,7 +128,7 @@ fn code_point_at() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -162,7 +162,7 @@ fn concat() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -196,7 +196,7 @@ fn includes() {
|
||||
this.includes(search_value, position)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -231,7 +231,7 @@ fn index_of() {
|
||||
this.index_of(search_value, from_index)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -274,7 +274,7 @@ fn slice() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -305,7 +305,7 @@ fn starts_with() {
|
||||
this.starts_with(search_string, position)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -336,7 +336,7 @@ fn substring() {
|
||||
this.substring(index_start, index_end)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -375,7 +375,7 @@ fn substr() {
|
||||
this.substr(start, length)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -411,7 +411,7 @@ fn to_lower_case() {
|
||||
this.to_lower_case()
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -441,7 +441,7 @@ fn to_string() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -470,7 +470,7 @@ fn to_upper_case() {
|
||||
this.to_upper_case()
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -500,7 +500,7 @@ fn trim() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -539,7 +539,7 @@ fn trim_end_and_trim_right() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -579,7 +579,7 @@ fn trim_start_and_trim_left() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -614,7 +614,7 @@ fn value_of() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
@ -17,7 +17,7 @@ fn clear() {
|
||||
this.clear();
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -49,7 +49,7 @@ fn delete() {
|
||||
this.delete(key)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -81,7 +81,7 @@ fn get() {
|
||||
this.get(key)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -112,7 +112,7 @@ fn has() {
|
||||
this.has(key)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -141,7 +141,7 @@ fn new() {
|
||||
js::Map::new()
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -169,7 +169,7 @@ fn set() {
|
||||
this.set(key, value)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -198,7 +198,7 @@ fn size() {
|
||||
this.size()
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
|
@ -18,7 +18,7 @@ fn entries() {
|
||||
this.entries()
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -50,7 +50,7 @@ fn keys() {
|
||||
this.keys()
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -82,7 +82,7 @@ fn values() {
|
||||
this.values()
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
|
@ -21,7 +21,7 @@ fn abs() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -55,7 +55,7 @@ fn acos() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -63,7 +63,7 @@ fn acos() {
|
||||
export function test() {
|
||||
assert.equal(wasm.acos(-1), Math.PI);
|
||||
assert.equal(wasm.acos(0.5), 1.0471975511965979);
|
||||
assert(Number.isNaN(wasm.acos(2)));
|
||||
assert.ok(Number.isNaN(wasm.acos(2)));
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -89,7 +89,7 @@ fn acosh() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -97,7 +97,7 @@ fn acosh() {
|
||||
export function test() {
|
||||
assert.equal(wasm.acosh(1), 0);
|
||||
assert.equal(wasm.acosh(2), Math.acosh(2));
|
||||
assert(Number.isNaN(wasm.acosh(0.5)));
|
||||
assert.ok(Number.isNaN(wasm.acosh(0.5)));
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -123,7 +123,7 @@ fn asin() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -131,7 +131,7 @@ fn asin() {
|
||||
export function test() {
|
||||
assert.equal(wasm.asin(1), Math.asin(1));
|
||||
assert.equal(wasm.asin(0.5), Math.asin(0.5));
|
||||
assert(Number.isNaN(wasm.asin(2)));
|
||||
assert.ok(Number.isNaN(wasm.asin(2)));
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -157,7 +157,7 @@ fn asinh() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -190,7 +190,7 @@ fn atan() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -223,7 +223,7 @@ fn atan2() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -256,7 +256,7 @@ fn atanh() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -264,7 +264,7 @@ fn atanh() {
|
||||
export function test() {
|
||||
assert.equal(wasm.atanh(1), Math.atanh(1));
|
||||
assert.equal(wasm.atanh(0.5), Math.atanh(0.5));
|
||||
assert(Number.isNaN(wasm.atanh(2)));
|
||||
assert.ok(Number.isNaN(wasm.atanh(2)));
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -290,7 +290,7 @@ fn cbrt() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -323,7 +323,7 @@ fn ceil() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -356,7 +356,7 @@ fn clz32() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -385,7 +385,7 @@ fn cos() {
|
||||
js::Math::cos(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -412,7 +412,7 @@ fn cosh() {
|
||||
js::Math::cosh(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -439,7 +439,7 @@ fn exp() {
|
||||
js::Math::exp(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -467,7 +467,7 @@ fn expm1() {
|
||||
js::Math::expm1(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -500,7 +500,7 @@ fn floor() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -529,7 +529,7 @@ fn fround() {
|
||||
js::Math::fround(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -558,7 +558,7 @@ fn imul() {
|
||||
js::Math::imul(x, y)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -586,7 +586,7 @@ fn log() {
|
||||
js::Math::log(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -613,7 +613,7 @@ fn log10() {
|
||||
js::Math::log10(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -641,7 +641,7 @@ fn log1p() {
|
||||
js::Math::log1p(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -649,7 +649,7 @@ fn log1p() {
|
||||
assert.equal(wasm.log1p(1), 0.6931471805599453);
|
||||
assert.equal(wasm.log1p(0), 0);
|
||||
assert.equal(wasm.log1p(-1), -Infinity);
|
||||
assert(isNaN(wasm.log1p(-2)));
|
||||
assert.ok(isNaN(wasm.log1p(-2)));
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
@ -670,7 +670,7 @@ fn log2() {
|
||||
js::Math::log2(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -699,14 +699,14 @@ fn pow() {
|
||||
js::Math::pow(base, exponent)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
assert.equal(wasm.pow(7, 2), 49);
|
||||
assert.equal(wasm.pow(3.8, 0.5), Math.pow(3.8, 0.5));
|
||||
assert(Number.isNaN(wasm.pow(-2, 0.5)));
|
||||
assert.ok(Number.isNaN(wasm.pow(-2, 0.5)));
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
@ -727,7 +727,7 @@ fn round() {
|
||||
js::Math::round(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -757,7 +757,7 @@ fn sign() {
|
||||
js::Math::sign(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -766,7 +766,7 @@ fn sign() {
|
||||
assert.equal(wasm.sign(-3), -1);
|
||||
assert.equal(wasm.sign(2.3), 1);
|
||||
assert.equal(wasm.sign(0), 0);
|
||||
assert(Number.isNaN(wasm.sign(NaN)));
|
||||
assert.ok(Number.isNaN(wasm.sign(NaN)));
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
@ -787,7 +787,7 @@ fn sin() {
|
||||
js::Math::sin(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -815,7 +815,7 @@ fn sinh() {
|
||||
js::Math::sinh(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -843,7 +843,7 @@ fn sqrt() {
|
||||
js::Math::sqrt(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -852,7 +852,7 @@ fn sqrt() {
|
||||
assert.equal(wasm.sqrt(2), Math.sqrt(2));
|
||||
assert.equal(wasm.sqrt(42.42), Math.sqrt(42.42));
|
||||
assert.equal(wasm.sqrt(1), 1);
|
||||
assert(Number.isNaN(wasm.sqrt(-1)));
|
||||
assert.ok(Number.isNaN(wasm.sqrt(-1)));
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
@ -873,7 +873,7 @@ fn tan() {
|
||||
js::Math::tan(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -901,7 +901,7 @@ fn tanh() {
|
||||
js::Math::tanh(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -929,7 +929,7 @@ fn trunc() {
|
||||
js::Math::trunc(x)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
|
@ -17,7 +17,7 @@ fn new() {
|
||||
Number::new(JsValue::from(42))
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -44,7 +44,7 @@ fn to_locale_string() {
|
||||
this.to_locale_string(locale)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -83,7 +83,7 @@ fn to_precision() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -121,7 +121,7 @@ fn to_string() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -156,7 +156,7 @@ fn value_of() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -195,7 +195,7 @@ fn to_fixed() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -233,7 +233,7 @@ fn to_exponential() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
@ -21,7 +21,7 @@ fn new() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -53,18 +53,18 @@ fn has_own_property() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
assert(wasm.has_own_foo_property({ foo: 42 }, "foo"));
|
||||
assert(wasm.has_own_foo_property({ 42: "foo" }, 42));
|
||||
assert(!wasm.has_own_foo_property({ foo: 42 }, "bar"));
|
||||
assert.ok(wasm.has_own_foo_property({ foo: 42 }, "foo"));
|
||||
assert.ok(wasm.has_own_foo_property({ 42: "foo" }, 42));
|
||||
assert.ok(!wasm.has_own_foo_property({ foo: 42 }, "bar"));
|
||||
|
||||
const s = Symbol();
|
||||
assert(wasm.has_own_foo_property({ [s]: "foo" }, s));
|
||||
assert.ok(wasm.has_own_foo_property({ [s]: "foo" }, s));
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -96,7 +96,7 @@ fn to_string() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -125,16 +125,16 @@ fn is_extensible() {
|
||||
js::Object::is_extensible(&obj)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
const object = {};
|
||||
assert(wasm.is_extensible(object));
|
||||
assert.ok(wasm.is_extensible(object));
|
||||
|
||||
Object.preventExtensions(object);
|
||||
assert(!wasm.is_extensible(object));
|
||||
assert.ok(!wasm.is_extensible(object));
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
@ -155,16 +155,16 @@ fn is_frozen() {
|
||||
js::Object::is_frozen(&obj)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
const object = {};
|
||||
assert(!wasm.is_frozen(object));
|
||||
assert.ok(!wasm.is_frozen(object));
|
||||
|
||||
Object.freeze(object);
|
||||
assert(wasm.is_frozen(object));
|
||||
assert.ok(wasm.is_frozen(object));
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
@ -185,16 +185,16 @@ fn is_sealed() {
|
||||
js::Object::is_sealed(&obj)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
const object = {};
|
||||
assert(!wasm.is_sealed(object));
|
||||
assert.ok(!wasm.is_sealed(object));
|
||||
|
||||
Object.seal(object);
|
||||
assert(wasm.is_sealed(object));
|
||||
assert.ok(wasm.is_sealed(object));
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
@ -219,7 +219,7 @@ fn is_prototype_of() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -229,8 +229,8 @@ fn is_prototype_of() {
|
||||
|
||||
export function test() {
|
||||
const foo = new Foo();
|
||||
assert(wasm.obj_is_prototype_of_value(Foo.prototype, foo));
|
||||
assert(!wasm.obj_is_prototype_of_value(Bar.prototype, foo));
|
||||
assert.ok(wasm.obj_is_prototype_of_value(Foo.prototype, foo));
|
||||
assert.ok(!wasm.obj_is_prototype_of_value(Bar.prototype, foo));
|
||||
}
|
||||
"#,
|
||||
)
|
||||
@ -256,7 +256,7 @@ fn keys() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -285,7 +285,7 @@ fn prevent_extensions() {
|
||||
js::Object::prevent_extensions(obj);
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -293,7 +293,7 @@ fn prevent_extensions() {
|
||||
const object = {};
|
||||
wasm.prevent_extensions(object);
|
||||
|
||||
assert(!Object.isExtensible(object));
|
||||
assert.ok(!Object.isExtensible(object));
|
||||
assert.throws(() => {
|
||||
'use strict';
|
||||
Object.defineProperty(object, 'foo', { value: 42 });
|
||||
@ -322,19 +322,19 @@ fn property_is_enumerable() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
assert(wasm.property_is_enumerable({ foo: 42 }, "foo"));
|
||||
assert(wasm.property_is_enumerable({ 42: "foo" }, 42));
|
||||
assert(!wasm.property_is_enumerable({}, 42));
|
||||
assert.ok(wasm.property_is_enumerable({ foo: 42 }, "foo"));
|
||||
assert.ok(wasm.property_is_enumerable({ 42: "foo" }, 42));
|
||||
assert.ok(!wasm.property_is_enumerable({}, 42));
|
||||
|
||||
const obj = {};
|
||||
Object.defineProperty(obj, "foo", { enumerable: false });
|
||||
assert(!wasm.property_is_enumerable(obj, "foo"));
|
||||
assert.ok(!wasm.property_is_enumerable(obj, "foo"));
|
||||
|
||||
const s = Symbol();
|
||||
assert.ok(wasm.property_is_enumerable({ [s]: true }, s));
|
||||
@ -359,12 +359,12 @@ fn seal() {
|
||||
js::Object::seal(&value)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
const object: any = { foo: 'bar' };
|
||||
const object = { foo: 'bar' };
|
||||
const sealedObject = wasm.seal(object);
|
||||
assert.strictEqual(object, sealedObject);
|
||||
assert.throws(() => {
|
||||
@ -410,7 +410,7 @@ fn set_prototype_of() {
|
||||
js::Object::set_prototype_of(&object, &prototype)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -419,7 +419,7 @@ fn set_prototype_of() {
|
||||
const newPrototype = { bar: 'baz' };
|
||||
|
||||
const modifiedObject = wasm.set_prototype_of(object, newPrototype);
|
||||
assert(newPrototype.isPrototypeOf(modifiedObject));
|
||||
assert.ok(newPrototype.isPrototypeOf(modifiedObject));
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
@ -445,7 +445,7 @@ fn to_locale_string() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -477,7 +477,7 @@ fn value_of() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -507,7 +507,7 @@ fn values() {
|
||||
js::Object::values(&obj)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
|
@ -18,7 +18,7 @@ fn add() {
|
||||
}
|
||||
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -51,7 +51,7 @@ fn clear() {
|
||||
}
|
||||
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -81,7 +81,7 @@ fn delete() {
|
||||
this.delete(value)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -110,7 +110,7 @@ fn has() {
|
||||
this.has(value)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -139,7 +139,7 @@ fn new() {
|
||||
js::Set::new()
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -168,7 +168,7 @@ fn size() {
|
||||
}
|
||||
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
|
@ -18,7 +18,7 @@ fn entries() {
|
||||
}
|
||||
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -50,7 +50,7 @@ fn keys() {
|
||||
}
|
||||
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -81,7 +81,7 @@ fn values() {
|
||||
}
|
||||
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
|
@ -21,7 +21,7 @@ fn new_undefined() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -53,7 +53,7 @@ fn new_length() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -81,7 +81,7 @@ fn fill() {
|
||||
this.fill(value, start, end)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
.file("test.js", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
|
@ -21,7 +21,7 @@ fn new() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -53,7 +53,7 @@ fn get() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -91,7 +91,7 @@ fn set() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -126,7 +126,7 @@ fn has() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -164,7 +164,7 @@ fn delete() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
@ -21,7 +21,7 @@ fn new() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -53,7 +53,7 @@ fn has() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -91,7 +91,7 @@ fn add() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -132,7 +132,7 @@ fn delete() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
@ -24,21 +24,21 @@ fn simple() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out";
|
||||
import * as assert from "assert";
|
||||
|
||||
let ARG: string | null = null;
|
||||
let ARG = null;
|
||||
|
||||
export function foo(s: any): void {
|
||||
export function foo(s) {
|
||||
assert.strictEqual(ARG, null);
|
||||
ARG = s;
|
||||
}
|
||||
|
||||
export function test() {
|
||||
assert.strictEqual(ARG, null);
|
||||
let sym = (Symbol as any)('test');
|
||||
let sym = Symbol('test');
|
||||
wasm.bar(sym);
|
||||
assert.strictEqual(ARG, sym);
|
||||
}
|
||||
@ -71,21 +71,21 @@ fn owned() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out";
|
||||
import * as assert from "assert";
|
||||
|
||||
let ARG: any = null;
|
||||
let ARG = null;
|
||||
|
||||
export function foo(s: any): void {
|
||||
export function foo(s) {
|
||||
assert.strictEqual(ARG, null);
|
||||
ARG = s;
|
||||
}
|
||||
|
||||
export function test() {
|
||||
assert.strictEqual(ARG, null);
|
||||
let sym = (Symbol as any)('test');
|
||||
let sym = Symbol('test');
|
||||
wasm.bar(sym);
|
||||
assert.strictEqual(ARG, sym);
|
||||
}
|
||||
@ -126,18 +126,18 @@ fn clone() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out";
|
||||
import * as assert from "assert";
|
||||
|
||||
let ARG = (Symbol as any)('test');
|
||||
let ARG = Symbol('test');
|
||||
|
||||
export function foo1(s: any): void { assert.strictEqual(s, ARG); }
|
||||
export function foo2(s: any): void { assert.strictEqual(s, ARG); }
|
||||
export function foo3(s: any): void { assert.strictEqual(s, ARG); }
|
||||
export function foo4(s: any): void { assert.strictEqual(s, ARG); }
|
||||
export function foo5(s: any): void { assert.strictEqual(s, ARG); }
|
||||
export function foo1(s) { assert.strictEqual(s, ARG); }
|
||||
export function foo2(s) { assert.strictEqual(s, ARG); }
|
||||
export function foo3(s) { assert.strictEqual(s, ARG); }
|
||||
export function foo4(s) { assert.strictEqual(s, ARG); }
|
||||
export function foo5(s) { assert.strictEqual(s, ARG); }
|
||||
|
||||
export function test() {
|
||||
wasm.bar(ARG);
|
||||
@ -177,17 +177,17 @@ fn promote() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out";
|
||||
import * as assert from "assert";
|
||||
|
||||
let ARG = (Symbol as any)('test');
|
||||
let ARG = Symbol('test');
|
||||
|
||||
export function foo1(s: any): void { assert.strictEqual(s, ARG); }
|
||||
export function foo2(s: any): void { assert.strictEqual(s, ARG); }
|
||||
export function foo3(s: any): void { assert.strictEqual(s, ARG); }
|
||||
export function foo4(s: any): void { assert.strictEqual(s, ARG); }
|
||||
export function foo1(s) { assert.strictEqual(s, ARG); }
|
||||
export function foo2(s) { assert.strictEqual(s, ARG); }
|
||||
export function foo3(s) { assert.strictEqual(s, ARG); }
|
||||
export function foo4(s) { assert.strictEqual(s, ARG); }
|
||||
|
||||
export function test() {
|
||||
wasm.bar(ARG);
|
||||
@ -225,12 +225,12 @@ fn returning_vector() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function foo(): any { return { "foo": "bar" }; }
|
||||
export function foo() { return { "foo": "bar" }; }
|
||||
|
||||
export function test() {
|
||||
const result = wasm.bar();
|
||||
@ -268,7 +268,7 @@ fn another_vector_return() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { get_array } from "./out";
|
||||
import * as assert from "assert";
|
||||
@ -344,12 +344,12 @@ fn serde() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { run, parse } from "./out";
|
||||
import * as assert from "assert";
|
||||
|
||||
export function verify(a: any) {
|
||||
export function verify(a) {
|
||||
assert.deepStrictEqual(a, {
|
||||
a: 0,
|
||||
b: 'foo',
|
||||
|
@ -1,544 +1,7 @@
|
||||
extern crate wasm_bindgen_cli_support as cli;
|
||||
extern crate wasm_bindgen_cli_support;
|
||||
|
||||
use std::env;
|
||||
use std::fs::{self, File};
|
||||
use std::io::{self, Read, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Stdio};
|
||||
use std::sync::atomic::*;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
use std::time::Instant;
|
||||
|
||||
static CNT: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
thread_local!(static IDX: usize = CNT.fetch_add(1, Ordering::SeqCst));
|
||||
|
||||
struct Project {
|
||||
files: Vec<(String, String)>,
|
||||
debug: bool,
|
||||
node: bool,
|
||||
no_std: bool,
|
||||
serde: bool,
|
||||
rlib: bool,
|
||||
node_args: Vec<String>,
|
||||
deps: Vec<String>,
|
||||
}
|
||||
|
||||
fn project() -> Project {
|
||||
let dir = Path::new(env!("CARGO_MANIFEST_DIR"));
|
||||
let mut lockfile = String::new();
|
||||
fs::File::open(&dir.join("Cargo.lock"))
|
||||
.unwrap()
|
||||
.read_to_string(&mut lockfile)
|
||||
.unwrap();
|
||||
Project {
|
||||
debug: true,
|
||||
node: false,
|
||||
no_std: false,
|
||||
serde: false,
|
||||
rlib: false,
|
||||
deps: Vec::new(),
|
||||
node_args: Vec::new(),
|
||||
files: vec![
|
||||
("Cargo.lock".to_string(), lockfile),
|
||||
(
|
||||
"run-node.js".to_string(),
|
||||
r#"require("./test").test();"#.to_string(),
|
||||
),
|
||||
(
|
||||
"webpack.config.js".to_string(),
|
||||
r#"
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
let nodeModules = {};
|
||||
|
||||
// Webpack bundles the modules from node_modules.
|
||||
// For node target, we will not have `fs` module
|
||||
// inside the `node_modules` folder.
|
||||
// This reads the directories in `node_modules`
|
||||
// and give that to externals and webpack ignores
|
||||
// to bundle the modules listed as external.
|
||||
fs.readdirSync('node_modules')
|
||||
.filter(module => module !== '.bin')
|
||||
.forEach(mod => {
|
||||
// External however,expects browser environment.
|
||||
// To make it work in `node` target we
|
||||
// prefix commonjs here.
|
||||
nodeModules[mod] = 'commonjs ' + mod;
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
entry: './run.js',
|
||||
mode: "development",
|
||||
devtool: "source-map",
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.ts$/,
|
||||
use: 'ts-loader',
|
||||
exclude: /node_modules/
|
||||
}
|
||||
]
|
||||
},
|
||||
resolve: {
|
||||
extensions: [ '.ts', '.js', '.wasm' ]
|
||||
},
|
||||
output: {
|
||||
filename: 'bundle.js',
|
||||
path: path.resolve(__dirname, '.')
|
||||
},
|
||||
target: 'node',
|
||||
externals: nodeModules
|
||||
};
|
||||
"#.to_string(),
|
||||
),
|
||||
(
|
||||
"tsconfig.json".to_string(),
|
||||
r#"
|
||||
{
|
||||
"compilerOptions": {
|
||||
"noEmitOnError": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"noUnusedParameters": true,
|
||||
"noUnusedLocals": true,
|
||||
"noImplicitReturns": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"alwaysStrict": true,
|
||||
"strict": true,
|
||||
"target": "es5",
|
||||
"lib": ["es2015"]
|
||||
}
|
||||
}
|
||||
"#.to_string(),
|
||||
),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
fn root() -> PathBuf {
|
||||
let idx = IDX.with(|x| *x);
|
||||
|
||||
let mut me = env::current_exe().unwrap();
|
||||
me.pop(); // chop off exe name
|
||||
me.pop(); // chop off `deps`
|
||||
me.pop(); // chop off `debug` / `release`
|
||||
me.push("generated-tests");
|
||||
me.push(&format!("test{}", idx));
|
||||
return me;
|
||||
}
|
||||
|
||||
fn assert_bigint_support() -> Option<&'static str> {
|
||||
static BIGINT_SUPPORED: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
static INIT: Once = ONCE_INIT;
|
||||
|
||||
INIT.call_once(|| {
|
||||
let mut cmd = Command::new("node");
|
||||
cmd.arg("-e").arg("BigInt");
|
||||
cmd.stdin(Stdio::null())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped());
|
||||
if cmd.status().unwrap().success() {
|
||||
BIGINT_SUPPORED.store(1, Ordering::SeqCst);
|
||||
return;
|
||||
}
|
||||
|
||||
cmd.arg("--harmony-bigint");
|
||||
if cmd.status().unwrap().success() {
|
||||
BIGINT_SUPPORED.store(2, Ordering::SeqCst);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
match BIGINT_SUPPORED.load(Ordering::SeqCst) {
|
||||
1 => return None,
|
||||
2 => return Some("--harmony-bigint"),
|
||||
_ => panic!(
|
||||
"the version of node.js that is installed for these tests \
|
||||
does not support `BigInt`, you may wish to try installing \
|
||||
node 10 to fix this"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
impl Project {
|
||||
fn file(&mut self, name: &str, contents: &str) -> &mut Project {
|
||||
self.files.push((name.to_string(), contents.to_string()));
|
||||
self
|
||||
}
|
||||
|
||||
fn debug(&mut self, debug: bool) -> &mut Project {
|
||||
self.debug = debug;
|
||||
self
|
||||
}
|
||||
|
||||
fn node(&mut self, node: bool) -> &mut Project {
|
||||
self.node = node;
|
||||
self
|
||||
}
|
||||
|
||||
fn no_std(&mut self, no_std: bool) -> &mut Project {
|
||||
self.no_std = no_std;
|
||||
self
|
||||
}
|
||||
|
||||
fn serde(&mut self, serde: bool) -> &mut Project {
|
||||
self.serde = serde;
|
||||
self
|
||||
}
|
||||
|
||||
fn rlib(&mut self, rlib: bool) -> &mut Project {
|
||||
self.rlib = rlib;
|
||||
self
|
||||
}
|
||||
|
||||
fn depend(&mut self, dep: &str) -> &mut Project {
|
||||
self.deps.push(dep.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
fn add_local_dependency(&mut self, name: &str, path: &str) -> &mut Project {
|
||||
self.deps
|
||||
.push(format!("{} = {{ path = '{}' }}", name, path));
|
||||
self
|
||||
}
|
||||
|
||||
fn crate_name(&self) -> String {
|
||||
format!("test{}", IDX.with(|x| *x))
|
||||
}
|
||||
|
||||
fn requires_bigint(&mut self) -> &mut Project {
|
||||
if let Some(arg) = assert_bigint_support() {
|
||||
self.node_args.push(arg.to_string());
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
fn generate_webidl_bindings(&mut self) -> Vec<PathBuf> {
|
||||
let mut res = Vec::new();
|
||||
let mut origpaths = Vec::new();
|
||||
|
||||
for (path, _) in &self.files {
|
||||
let path = Path::new(&path);
|
||||
let extension = path.extension().map(|x| x.to_str().unwrap());
|
||||
|
||||
if extension != Some("webidl") {
|
||||
continue;
|
||||
}
|
||||
|
||||
res.push(path.with_extension("rs"));
|
||||
origpaths.push(path.to_owned());
|
||||
}
|
||||
|
||||
if res.is_empty() {
|
||||
return res;
|
||||
}
|
||||
|
||||
let mut buildrs = r#"
|
||||
extern crate wasm_bindgen_webidl;
|
||||
|
||||
use wasm_bindgen_webidl::compile_file;
|
||||
use std::env;
|
||||
use std::fs::{self, File};
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
let dest = env::var("OUT_DIR").unwrap();
|
||||
"#.to_string();
|
||||
|
||||
for (path, origpath) in res.iter().zip(origpaths.iter()) {
|
||||
buildrs.push_str(&format!(
|
||||
r#"
|
||||
fs::create_dir_all("{}").unwrap();
|
||||
File::create(&Path::new(&dest).join("{}"))
|
||||
.unwrap()
|
||||
.write_all(
|
||||
compile_file(Path::new("{}"))
|
||||
.unwrap()
|
||||
.as_bytes()
|
||||
)
|
||||
.unwrap();
|
||||
"#,
|
||||
path.parent().unwrap().to_str().unwrap(),
|
||||
path.to_str().unwrap(),
|
||||
origpath.to_str().unwrap(),
|
||||
));
|
||||
|
||||
self.files.push((
|
||||
Path::new("src").join(path).to_str().unwrap().to_string(),
|
||||
format!(
|
||||
r#"include!(concat!(env!("OUT_DIR"), "/{}"));"#,
|
||||
path.display()
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
buildrs.push('}');
|
||||
|
||||
self.files.push(("build.rs".to_string(), buildrs));
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
fn generate_js_entry(&mut self, modules: Vec<PathBuf>) {
|
||||
let mut runjs = r#"
|
||||
import * as process from "process";
|
||||
"#.to_string();
|
||||
|
||||
if !modules.is_empty() {
|
||||
runjs.push_str(r#"Promise.all(["#);
|
||||
for module in &modules {
|
||||
runjs.push_str(&format!(
|
||||
r#"import('./{}'),"#,
|
||||
module.with_extension("").to_str().unwrap()
|
||||
));
|
||||
}
|
||||
runjs.push_str(
|
||||
r#"]).then(results => { results.map(module => Object.assign(global, module));"#,
|
||||
);
|
||||
}
|
||||
|
||||
runjs.push_str(
|
||||
r#"
|
||||
let wasm = import('./out');
|
||||
const test = import('./test');
|
||||
"#,
|
||||
);
|
||||
|
||||
if !modules.is_empty() {
|
||||
runjs.push_str("return ");
|
||||
}
|
||||
|
||||
runjs.push_str(r#"Promise.all([test, wasm])"#);
|
||||
|
||||
if !modules.is_empty() {
|
||||
runjs.push_str("})");
|
||||
}
|
||||
|
||||
runjs.push_str(
|
||||
r#"
|
||||
.then(results => {
|
||||
let [test, wasm] = results;
|
||||
test.test();
|
||||
|
||||
if (wasm.assertStackEmpty)
|
||||
wasm.assertStackEmpty();
|
||||
if (wasm.assertSlabEmpty)
|
||||
wasm.assertSlabEmpty();
|
||||
})
|
||||
.catch(error => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
"#,
|
||||
);
|
||||
self.files.push(("run.js".to_string(), runjs));
|
||||
}
|
||||
|
||||
fn ensure_test_entry(&mut self) {
|
||||
if !self
|
||||
.files
|
||||
.iter()
|
||||
.any(|(path, _)| path == "test.ts" || path == "test.js")
|
||||
{
|
||||
self.files.push((
|
||||
"test.ts".to_string(),
|
||||
r#"export {test} from './out';"#.to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
/// build + cargo cmd execution
|
||||
fn cargo_build(&mut self) -> (PathBuf, PathBuf) {
|
||||
let (root, target_dir) = self.build();
|
||||
let mut cmd = Command::new("cargo");
|
||||
cmd.arg("build")
|
||||
.arg("--target")
|
||||
.arg("wasm32-unknown-unknown")
|
||||
.current_dir(&root)
|
||||
.env("CARGO_TARGET_DIR", &target_dir)
|
||||
// Catch any warnings in generated code because we don't want any
|
||||
.env("RUSTFLAGS", "-Dwarnings");
|
||||
run(&mut cmd, "cargo");
|
||||
(root, target_dir)
|
||||
}
|
||||
|
||||
fn build(&mut self) -> (PathBuf, PathBuf) {
|
||||
self.ensure_test_entry();
|
||||
|
||||
let webidl_modules = self.generate_webidl_bindings();
|
||||
self.generate_js_entry(webidl_modules);
|
||||
|
||||
let mut manifest = format!(
|
||||
r#"
|
||||
[package]
|
||||
name = "test{}"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[workspace]
|
||||
|
||||
[lib]
|
||||
"#,
|
||||
IDX.with(|x| *x)
|
||||
);
|
||||
|
||||
if !self.rlib {
|
||||
manifest.push_str("crate-type = [\"cdylib\"]\n");
|
||||
}
|
||||
|
||||
manifest.push_str("[build-dependencies]\n");
|
||||
manifest.push_str("wasm-bindgen-webidl = { path = '");
|
||||
manifest.push_str(env!("CARGO_MANIFEST_DIR"));
|
||||
manifest.push_str("/crates/webidl' }\n");
|
||||
|
||||
manifest.push_str("[dependencies]\n");
|
||||
for dep in self.deps.iter() {
|
||||
manifest.push_str(dep);
|
||||
manifest.push_str("\n");
|
||||
}
|
||||
manifest.push_str("wasm-bindgen = { path = '");
|
||||
manifest.push_str(env!("CARGO_MANIFEST_DIR"));
|
||||
manifest.push_str("'");
|
||||
if self.no_std {
|
||||
manifest.push_str(", default-features = false");
|
||||
}
|
||||
if self.serde {
|
||||
manifest.push_str(", features = ['serde-serialize']");
|
||||
}
|
||||
manifest.push_str(" }\n");
|
||||
self.files.push(("Cargo.toml".to_string(), manifest));
|
||||
|
||||
let root = root();
|
||||
drop(fs::remove_dir_all(&root));
|
||||
for &(ref file, ref contents) in self.files.iter() {
|
||||
let dst = root.join(file);
|
||||
fs::create_dir_all(dst.parent().unwrap()).unwrap();
|
||||
fs::File::create(&dst)
|
||||
.unwrap()
|
||||
.write_all(contents.as_ref())
|
||||
.unwrap();
|
||||
}
|
||||
let target_dir = root.parent().unwrap() // chop off test name
|
||||
.parent().unwrap(); // chop off `generated-tests`
|
||||
(root.clone(), target_dir.to_path_buf())
|
||||
}
|
||||
|
||||
fn test(&mut self) {
|
||||
let (root, target_dir) = self.cargo_build();
|
||||
|
||||
self.gen_bindings(&root, &target_dir);
|
||||
let mut wasm = Vec::new();
|
||||
File::open(root.join("out_bg.wasm"))
|
||||
.unwrap()
|
||||
.read_to_end(&mut wasm)
|
||||
.unwrap();
|
||||
let obj = cli::wasm2es6js::Config::new()
|
||||
.base64(true)
|
||||
.generate(&wasm)
|
||||
.expect("failed to convert wasm to js");
|
||||
|
||||
File::create(root.join("out_bg.d.ts"))
|
||||
.unwrap()
|
||||
.write_all(obj.typescript().as_bytes())
|
||||
.unwrap();
|
||||
|
||||
// move files from the root into each test, it looks like this may be
|
||||
// needed for webpack to work well when invoked concurrently.
|
||||
fs::hard_link("package.json", root.join("package.json")).unwrap();
|
||||
if !Path::new("node_modules").exists() {
|
||||
panic!("\n\nfailed to find `node_modules`, have you run `npm install` yet?\n\n");
|
||||
}
|
||||
let cwd = env::current_dir().unwrap();
|
||||
symlink_dir(&cwd.join("node_modules"), &root.join("node_modules")).unwrap();
|
||||
|
||||
if self.node {
|
||||
let mut cmd = Command::new("node");
|
||||
cmd.args(&self.node_args);
|
||||
cmd.arg(root.join("run-node.js")).current_dir(&root);
|
||||
run(&mut cmd, "node");
|
||||
} else {
|
||||
let mut cmd = if cfg!(windows) {
|
||||
let mut c = Command::new("cmd");
|
||||
c.arg("/c");
|
||||
c.arg("npm");
|
||||
c
|
||||
} else {
|
||||
Command::new("npm")
|
||||
};
|
||||
cmd.arg("run").arg("run-webpack").current_dir(&root);
|
||||
run(&mut cmd, "npm");
|
||||
|
||||
let mut cmd = Command::new("node");
|
||||
cmd.args(&self.node_args);
|
||||
cmd.arg(root.join("bundle.js")).current_dir(&root);
|
||||
run(&mut cmd, "node");
|
||||
}
|
||||
}
|
||||
/// execute the cli against the current test .wasm
|
||||
fn gen_bindings(&self, root: &PathBuf, target_dir: &PathBuf) {
|
||||
let idx = IDX.with(|x| *x);
|
||||
let out = target_dir.join(&format!("wasm32-unknown-unknown/debug/test{}.wasm", idx));
|
||||
|
||||
let as_a_module = root.join("out.wasm");
|
||||
fs::copy(&out, &as_a_module).unwrap();
|
||||
|
||||
let res = cli::Bindgen::new()
|
||||
.input_path(&as_a_module)
|
||||
.typescript(true)
|
||||
.nodejs(self.node)
|
||||
.debug(self.debug)
|
||||
.generate(&root);
|
||||
if let Err(e) = res {
|
||||
for e in e.causes() {
|
||||
println!("- {}", e);
|
||||
}
|
||||
panic!("failed");
|
||||
}
|
||||
}
|
||||
fn read_js(&self) -> String {
|
||||
let path = root().join("out.js");
|
||||
println!("js, {:?}", &path);
|
||||
fs::read_to_string(path).expect("Unable to read js")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn symlink_dir(a: &Path, b: &Path) -> io::Result<()> {
|
||||
use std::os::unix::fs::symlink;
|
||||
symlink(a, b)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn symlink_dir(a: &Path, b: &Path) -> io::Result<()> {
|
||||
use std::os::windows::fs::symlink_dir;
|
||||
symlink_dir(a, b)
|
||||
}
|
||||
|
||||
fn run(cmd: &mut Command, program: &str) {
|
||||
println!("···················································");
|
||||
println!("running {:?}", cmd);
|
||||
let start = Instant::now();
|
||||
let output = match cmd.output() {
|
||||
Ok(output) => output,
|
||||
Err(err) => panic!("failed to spawn `{}`: {}", program, err),
|
||||
};
|
||||
println!("exit: {}", output.status);
|
||||
let dur = start.elapsed();
|
||||
println!(
|
||||
"dur: {}.{:03}ms",
|
||||
dur.as_secs(),
|
||||
dur.subsec_nanos() / 1_000_000
|
||||
);
|
||||
if output.stdout.len() > 0 {
|
||||
println!("stdout ---\n{}", String::from_utf8_lossy(&output.stdout));
|
||||
}
|
||||
if output.stderr.len() > 0 {
|
||||
println!("stderr ---\n{}", String::from_utf8_lossy(&output.stderr));
|
||||
}
|
||||
assert!(output.status.success());
|
||||
}
|
||||
mod project_builder;
|
||||
use project_builder::{project, run};
|
||||
|
||||
mod api;
|
||||
mod char;
|
||||
@ -559,6 +22,7 @@ mod non_wasm;
|
||||
mod simple;
|
||||
mod slice;
|
||||
mod structural;
|
||||
mod typescript;
|
||||
mod u64;
|
||||
mod validate_prt;
|
||||
mod webidl;
|
||||
|
@ -69,7 +69,7 @@ fn auto_bind_math() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import { math } from "./out";
|
||||
|
||||
|
@ -3,7 +3,8 @@ use super::project;
|
||||
#[test]
|
||||
fn works() {
|
||||
project()
|
||||
.node(true)
|
||||
.debug(false)
|
||||
.nodejs_experimental_modules(false)
|
||||
.file(
|
||||
"src/lib.rs",
|
||||
r#"
|
||||
@ -125,6 +126,7 @@ fn works() {
|
||||
module.exports.hit = function() {
|
||||
called = true;
|
||||
};
|
||||
|
||||
module.exports.FOO = 1.0;
|
||||
|
||||
const { math, run, Foo, Color, cycle } = require('./out');
|
||||
@ -153,7 +155,6 @@ fn works() {
|
||||
|
||||
math(1.0, 2.0);
|
||||
};
|
||||
|
||||
"#,
|
||||
)
|
||||
.test();
|
||||
|
@ -31,13 +31,13 @@ fn works() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
let sym = (Symbol as any)('a');
|
||||
let sym = Symbol('a');
|
||||
assert.strictEqual(wasm.clone(sym), sym);
|
||||
let a = wasm.A.new();
|
||||
a.free();
|
||||
|
640
tests/all/project_builder.rs
Normal file
640
tests/all/project_builder.rs
Normal file
@ -0,0 +1,640 @@
|
||||
use wasm_bindgen_cli_support as cli;
|
||||
|
||||
use std::env;
|
||||
use std::fs::{self, File};
|
||||
use std::io::{self, Read, Write};
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Stdio};
|
||||
use std::sync::atomic::*;
|
||||
use std::sync::{Once, ONCE_INIT};
|
||||
use std::time::Instant;
|
||||
|
||||
static CNT: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
thread_local!(static IDX: usize = CNT.fetch_add(1, Ordering::SeqCst));
|
||||
|
||||
pub struct Project {
|
||||
files: Vec<(String, String)>,
|
||||
debug: bool,
|
||||
node: bool,
|
||||
nodejs_experimental_modules: bool,
|
||||
no_std: bool,
|
||||
serde: bool,
|
||||
rlib: bool,
|
||||
webpack: bool,
|
||||
node_args: Vec<String>,
|
||||
deps: Vec<String>,
|
||||
}
|
||||
|
||||
pub fn project() -> Project {
|
||||
let dir = Path::new(env!("CARGO_MANIFEST_DIR"));
|
||||
let mut lockfile = String::new();
|
||||
fs::File::open(&dir.join("Cargo.lock"))
|
||||
.unwrap()
|
||||
.read_to_string(&mut lockfile)
|
||||
.unwrap();
|
||||
Project {
|
||||
debug: true,
|
||||
no_std: false,
|
||||
node: true,
|
||||
nodejs_experimental_modules: true,
|
||||
webpack: false,
|
||||
serde: false,
|
||||
rlib: false,
|
||||
deps: Vec::new(),
|
||||
node_args: Vec::new(),
|
||||
files: vec![
|
||||
("Cargo.lock".to_string(), lockfile),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
fn root() -> PathBuf {
|
||||
let idx = IDX.with(|x| *x);
|
||||
|
||||
let mut me = env::current_exe().unwrap();
|
||||
me.pop(); // chop off exe name
|
||||
me.pop(); // chop off `deps`
|
||||
me.pop(); // chop off `debug` / `release`
|
||||
me.push("generated-tests");
|
||||
me.push(&format!("test{}", idx));
|
||||
return me;
|
||||
}
|
||||
|
||||
fn assert_bigint_support() -> Option<&'static str> {
|
||||
static BIGINT_SUPPORED: AtomicUsize = ATOMIC_USIZE_INIT;
|
||||
static INIT: Once = ONCE_INIT;
|
||||
|
||||
INIT.call_once(|| {
|
||||
let mut cmd = Command::new("node");
|
||||
cmd.arg("-e").arg("BigInt");
|
||||
cmd.stdin(Stdio::null())
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped());
|
||||
if cmd.status().unwrap().success() {
|
||||
BIGINT_SUPPORED.store(1, Ordering::SeqCst);
|
||||
return;
|
||||
}
|
||||
|
||||
cmd.arg("--harmony-bigint");
|
||||
if cmd.status().unwrap().success() {
|
||||
BIGINT_SUPPORED.store(2, Ordering::SeqCst);
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
match BIGINT_SUPPORED.load(Ordering::SeqCst) {
|
||||
1 => return None,
|
||||
2 => return Some("--harmony-bigint"),
|
||||
_ => panic!(
|
||||
"the version of node.js that is installed for these tests \
|
||||
does not support `BigInt`, you may wish to try installing \
|
||||
node 10 to fix this"
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
impl Project {
|
||||
/// Add a new file with the specified contents to this project, the `name`
|
||||
/// can have slahes for files in subdirectories.
|
||||
pub fn file(&mut self, name: &str, contents: &str) -> &mut Project {
|
||||
self.files.push((name.to_string(), contents.to_string()));
|
||||
self
|
||||
}
|
||||
|
||||
/// Enable debug mode in wasm-bindgen for this test
|
||||
pub fn debug(&mut self, debug: bool) -> &mut Project {
|
||||
self.debug = debug;
|
||||
self
|
||||
}
|
||||
|
||||
/// Depend on `wasm-bindgen` without the `std` feature enabled.
|
||||
pub fn no_std(&mut self, no_std: bool) -> &mut Project {
|
||||
self.no_std = no_std;
|
||||
self
|
||||
}
|
||||
|
||||
/// Depend on the `serde` feature of `wasm-bindgen`
|
||||
pub fn serde(&mut self, serde: bool) -> &mut Project {
|
||||
self.serde = serde;
|
||||
self
|
||||
}
|
||||
|
||||
/// Generate an rlib instead of a cdylib in the generated Cargo project
|
||||
pub fn rlib(&mut self, rlib: bool) -> &mut Project {
|
||||
self.rlib = rlib;
|
||||
self
|
||||
}
|
||||
|
||||
/// Depend on a crate from crates.io, like serde.
|
||||
pub fn depend(&mut self, dep: &str) -> &mut Project {
|
||||
self.deps.push(dep.to_string());
|
||||
self
|
||||
}
|
||||
|
||||
/// Enables or disables node.js experimental modules output
|
||||
pub fn nodejs_experimental_modules(&mut self, node: bool) -> &mut Project {
|
||||
self.nodejs_experimental_modules = node;
|
||||
self
|
||||
}
|
||||
|
||||
/// Enables or disables the usage of webpack for this project
|
||||
pub fn webpack(&mut self, webpack: bool) -> &mut Project {
|
||||
self.webpack = webpack;
|
||||
self
|
||||
}
|
||||
|
||||
/// Add a path dependency to the generated project
|
||||
pub fn add_local_dependency(&mut self, name: &str, path: &str) -> &mut Project {
|
||||
self.deps
|
||||
.push(format!("{} = {{ path = '{}' }}", name, path));
|
||||
self
|
||||
}
|
||||
|
||||
/// Returns the crate name that will be used for the generated crate, this
|
||||
/// name changes between test runs and is generated at runtime.
|
||||
pub fn crate_name(&self) -> String {
|
||||
format!("test{}", IDX.with(|x| *x))
|
||||
}
|
||||
|
||||
/// Flag this project as requiring bigint support in Node
|
||||
pub fn requires_bigint(&mut self) -> &mut Project {
|
||||
if let Some(arg) = assert_bigint_support() {
|
||||
self.node_args.push(arg.to_string());
|
||||
}
|
||||
self
|
||||
}
|
||||
|
||||
/// Write this project to the filesystem, ensuring all files are ready to
|
||||
/// go.
|
||||
pub fn build(&mut self) -> (PathBuf, PathBuf) {
|
||||
if self.webpack {
|
||||
self.node = false;
|
||||
self.nodejs_experimental_modules = false;
|
||||
}
|
||||
|
||||
self.ensure_webpack_config();
|
||||
self.ensure_test_entry();
|
||||
|
||||
let webidl_modules = self.generate_webidl_bindings();
|
||||
self.generate_js_entry(webidl_modules);
|
||||
|
||||
let mut manifest = format!(
|
||||
r#"
|
||||
[package]
|
||||
name = "test{}"
|
||||
version = "0.0.1"
|
||||
authors = []
|
||||
|
||||
[workspace]
|
||||
|
||||
[lib]
|
||||
"#,
|
||||
IDX.with(|x| *x)
|
||||
);
|
||||
|
||||
if !self.rlib {
|
||||
manifest.push_str("crate-type = [\"cdylib\"]\n");
|
||||
}
|
||||
|
||||
manifest.push_str("[build-dependencies]\n");
|
||||
manifest.push_str("wasm-bindgen-webidl = { path = '");
|
||||
manifest.push_str(env!("CARGO_MANIFEST_DIR"));
|
||||
manifest.push_str("/crates/webidl' }\n");
|
||||
|
||||
manifest.push_str("[dependencies]\n");
|
||||
for dep in self.deps.iter() {
|
||||
manifest.push_str(dep);
|
||||
manifest.push_str("\n");
|
||||
}
|
||||
manifest.push_str("wasm-bindgen = { path = '");
|
||||
manifest.push_str(env!("CARGO_MANIFEST_DIR"));
|
||||
manifest.push_str("'");
|
||||
if self.no_std {
|
||||
manifest.push_str(", default-features = false");
|
||||
}
|
||||
if self.serde {
|
||||
manifest.push_str(", features = ['serde-serialize']");
|
||||
}
|
||||
manifest.push_str(" }\n");
|
||||
self.files.push(("Cargo.toml".to_string(), manifest));
|
||||
|
||||
let root = root();
|
||||
drop(fs::remove_dir_all(&root));
|
||||
for &(ref file, ref contents) in self.files.iter() {
|
||||
let mut dst = root.join(file);
|
||||
if self.nodejs_experimental_modules &&
|
||||
dst.extension().and_then(|s| s.to_str()) == Some("js")
|
||||
{
|
||||
dst = dst.with_extension("mjs");
|
||||
}
|
||||
if dst.extension().and_then(|s| s.to_str()) == Some("ts") &&
|
||||
!self.webpack
|
||||
{
|
||||
panic!("webpack needs to be enabled to use typescript");
|
||||
}
|
||||
fs::create_dir_all(dst.parent().unwrap()).unwrap();
|
||||
fs::File::create(&dst)
|
||||
.unwrap()
|
||||
.write_all(contents.as_ref())
|
||||
.unwrap();
|
||||
}
|
||||
let target_dir = root.parent().unwrap() // chop off test name
|
||||
.parent().unwrap(); // chop off `generated-tests`
|
||||
(root.clone(), target_dir.to_path_buf())
|
||||
}
|
||||
|
||||
fn ensure_webpack_config(&mut self) {
|
||||
if !self.webpack {
|
||||
return
|
||||
}
|
||||
|
||||
let needs_typescript = self.files.iter().any(|t| t.0.ends_with(".ts"));
|
||||
|
||||
let mut rules = String::new();
|
||||
let mut extensions = format!("'.js', '.wasm'");
|
||||
if needs_typescript {
|
||||
rules.push_str("
|
||||
{
|
||||
test: /.ts$/,
|
||||
use: 'ts-loader',
|
||||
exclude: /node_modules/,
|
||||
}
|
||||
");
|
||||
extensions.push_str(", '.ts'");
|
||||
}
|
||||
self.files.push((
|
||||
"webpack.config.js".to_string(),
|
||||
format!(r#"
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
let nodeModules = {{}};
|
||||
|
||||
// Webpack bundles the modules from node_modules.
|
||||
// For node target, we will not have `fs` module
|
||||
// inside the `node_modules` folder.
|
||||
// This reads the directories in `node_modules`
|
||||
// and give that to externals and webpack ignores
|
||||
// to bundle the modules listed as external.
|
||||
fs.readdirSync('node_modules')
|
||||
.filter(module => module !== '.bin')
|
||||
.forEach(mod => {{
|
||||
// External however,expects browser environment.
|
||||
// To make it work in `node` target we
|
||||
// prefix commonjs here.
|
||||
nodeModules[mod] = 'commonjs ' + mod;
|
||||
}});
|
||||
|
||||
module.exports = {{
|
||||
entry: './run.js',
|
||||
mode: "development",
|
||||
devtool: "source-map",
|
||||
module: {{
|
||||
rules: [{}]
|
||||
}},
|
||||
resolve: {{
|
||||
extensions: [{}]
|
||||
}},
|
||||
output: {{
|
||||
filename: 'bundle.js',
|
||||
path: path.resolve(__dirname, '.')
|
||||
}},
|
||||
target: 'node',
|
||||
externals: nodeModules
|
||||
}};
|
||||
"#, rules, extensions)
|
||||
));
|
||||
if needs_typescript {
|
||||
self.files.push((
|
||||
"tsconfig.json".to_string(),
|
||||
r#"
|
||||
{
|
||||
"compilerOptions": {
|
||||
"noEmitOnError": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"noUnusedParameters": true,
|
||||
"noUnusedLocals": true,
|
||||
"noImplicitReturns": true,
|
||||
"strictFunctionTypes": true,
|
||||
"strictNullChecks": true,
|
||||
"alwaysStrict": true,
|
||||
"strict": true,
|
||||
"target": "es5",
|
||||
"lib": ["es2015"]
|
||||
}
|
||||
}
|
||||
"#.to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
fn ensure_test_entry(&mut self) {
|
||||
if !self
|
||||
.files
|
||||
.iter()
|
||||
.any(|(path, _)| path == "test.ts" || path == "test.js")
|
||||
{
|
||||
self.files.push((
|
||||
"test.js".to_string(),
|
||||
r#"export {test} from './out';"#.to_string(),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
fn generate_webidl_bindings(&mut self) -> Vec<PathBuf> {
|
||||
let mut res = Vec::new();
|
||||
let mut origpaths = Vec::new();
|
||||
|
||||
for (path, _) in &self.files {
|
||||
let path = Path::new(&path);
|
||||
let extension = path.extension().map(|x| x.to_str().unwrap());
|
||||
|
||||
if extension != Some("webidl") {
|
||||
continue;
|
||||
}
|
||||
|
||||
res.push(path.with_extension("rs"));
|
||||
origpaths.push(path.to_owned());
|
||||
}
|
||||
|
||||
if res.is_empty() {
|
||||
return res;
|
||||
}
|
||||
|
||||
let mut buildrs = r#"
|
||||
extern crate wasm_bindgen_webidl;
|
||||
|
||||
use wasm_bindgen_webidl::compile_file;
|
||||
use std::env;
|
||||
use std::fs::{self, File};
|
||||
use std::io::Write;
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
let dest = env::var("OUT_DIR").unwrap();
|
||||
"#.to_string();
|
||||
|
||||
for (path, origpath) in res.iter().zip(origpaths.iter()) {
|
||||
buildrs.push_str(&format!(
|
||||
r#"
|
||||
fs::create_dir_all("{}").unwrap();
|
||||
File::create(&Path::new(&dest).join("{}"))
|
||||
.unwrap()
|
||||
.write_all(
|
||||
compile_file(Path::new("{}"))
|
||||
.unwrap()
|
||||
.as_bytes()
|
||||
)
|
||||
.unwrap();
|
||||
"#,
|
||||
path.parent().unwrap().to_str().unwrap(),
|
||||
path.to_str().unwrap(),
|
||||
origpath.to_str().unwrap(),
|
||||
));
|
||||
|
||||
self.files.push((
|
||||
Path::new("src").join(path).to_str().unwrap().to_string(),
|
||||
format!(
|
||||
r#"include!(concat!(env!("OUT_DIR"), "/{}"));"#,
|
||||
path.display()
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
buildrs.push('}');
|
||||
|
||||
self.files.push(("build.rs".to_string(), buildrs));
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
fn generate_js_entry(&mut self, modules: Vec<PathBuf>) {
|
||||
let mut runjs = String::new();
|
||||
let esm_imports = self.webpack || !self.node || self.nodejs_experimental_modules;
|
||||
|
||||
if esm_imports {
|
||||
runjs.push_str("import * as process from 'process';\n");
|
||||
} else {
|
||||
runjs.push_str("const process = require('process');\n");
|
||||
}
|
||||
|
||||
runjs.push_str("
|
||||
function run(test, wasm) {
|
||||
test.test();
|
||||
|
||||
if (wasm.assertStackEmpty)
|
||||
wasm.assertStackEmpty();
|
||||
if (wasm.assertSlabEmpty)
|
||||
wasm.assertSlabEmpty();
|
||||
}
|
||||
|
||||
function onerror(error) {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
}
|
||||
");
|
||||
|
||||
if esm_imports {
|
||||
runjs.push_str("const modules = [];\n");
|
||||
for module in modules.iter() {
|
||||
runjs.push_str(&format!("modules.push(import('./{}'))",
|
||||
module.with_extension("").display()));
|
||||
}
|
||||
let import_wasm = if self.debug {
|
||||
"import('./out')"
|
||||
} else {
|
||||
"new Promise((a, b) => a({}))"
|
||||
};
|
||||
runjs.push_str(&format!("
|
||||
Promise.all(modules)
|
||||
.then(results => {{
|
||||
results.map(module => Object.assign(global, module));
|
||||
return Promise.all([import('./test'), {}])
|
||||
}})
|
||||
.then(result => run(result[0], result[1]))
|
||||
.catch(onerror);
|
||||
", import_wasm));
|
||||
} else {
|
||||
assert!(!self.debug);
|
||||
assert!(modules.is_empty());
|
||||
runjs.push_str("
|
||||
const test = require('./test');
|
||||
try {
|
||||
run(test, {});
|
||||
} catch (e) {
|
||||
onerror(e);
|
||||
}
|
||||
");
|
||||
}
|
||||
self.files.push(("run.js".to_string(), runjs));
|
||||
}
|
||||
|
||||
/// Build the Cargo project for the wasm target, returning the root of the
|
||||
/// project and the target directory where output is located.
|
||||
pub fn cargo_build(&mut self) -> (PathBuf, PathBuf) {
|
||||
let (root, target_dir) = self.build();
|
||||
let mut cmd = Command::new("cargo");
|
||||
cmd.arg("build")
|
||||
.arg("--target")
|
||||
.arg("wasm32-unknown-unknown")
|
||||
.current_dir(&root)
|
||||
.env("CARGO_TARGET_DIR", &target_dir)
|
||||
// Catch any warnings in generated code because we don't want any
|
||||
.env("RUSTFLAGS", "-Dwarnings");
|
||||
run(&mut cmd, "cargo");
|
||||
(root, target_dir)
|
||||
}
|
||||
|
||||
/// Generate wasm-bindgen bindings for the compiled artifacts of this
|
||||
/// project, returning the root of the project as well as the target
|
||||
/// directory where output was generated.
|
||||
pub fn gen_bindings(&mut self) -> (PathBuf, PathBuf) {
|
||||
let (root, target_dir) = self.cargo_build();
|
||||
let idx = IDX.with(|x| *x);
|
||||
let out = target_dir.join(&format!("wasm32-unknown-unknown/debug/test{}.wasm", idx));
|
||||
|
||||
let as_a_module = root.join("out.wasm");
|
||||
fs::hard_link(&out, &as_a_module).unwrap();
|
||||
|
||||
let _x = wrap_step("running wasm-bindgen");
|
||||
let res = cli::Bindgen::new()
|
||||
.input_path(&as_a_module)
|
||||
.typescript(self.webpack)
|
||||
.debug(self.debug)
|
||||
.nodejs(self.node)
|
||||
.nodejs_experimental_modules(self.nodejs_experimental_modules)
|
||||
.generate(&root);
|
||||
|
||||
if let Err(e) = res {
|
||||
for e in e.causes() {
|
||||
println!("- {}", e);
|
||||
}
|
||||
panic!("failed");
|
||||
}
|
||||
|
||||
(root, target_dir)
|
||||
}
|
||||
|
||||
/// Execute this project's `run.js`, ensuring that everything runs through
|
||||
/// node or a browser correctly
|
||||
pub fn test(&mut self) {
|
||||
let (root, _target_dir) = self.gen_bindings();
|
||||
|
||||
if !self.webpack {
|
||||
let mut cmd = Command::new("node");
|
||||
cmd.args(&self.node_args);
|
||||
if self.nodejs_experimental_modules {
|
||||
cmd.arg("--experimental-modules").arg("run.mjs");
|
||||
} else {
|
||||
cmd.arg("run.js");
|
||||
}
|
||||
cmd.current_dir(&root);
|
||||
run(&mut cmd, "node");
|
||||
return
|
||||
}
|
||||
|
||||
// Generate typescript bindings for the wasm module
|
||||
{
|
||||
let _x = wrap_step("running wasm2es6js");
|
||||
let mut wasm = Vec::new();
|
||||
File::open(root.join("out_bg.wasm"))
|
||||
.unwrap()
|
||||
.read_to_end(&mut wasm)
|
||||
.unwrap();
|
||||
let obj = cli::wasm2es6js::Config::new()
|
||||
.base64(true)
|
||||
.generate(&wasm)
|
||||
.expect("failed to convert wasm to js");
|
||||
File::create(root.join("out_bg.d.ts"))
|
||||
.unwrap()
|
||||
.write_all(obj.typescript().as_bytes())
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
// move files from the root into each test, it looks like this may be
|
||||
// needed for webpack to work well when invoked concurrently.
|
||||
fs::hard_link("package.json", root.join("package.json")).unwrap();
|
||||
if !Path::new("node_modules").exists() {
|
||||
panic!("\n\nfailed to find `node_modules`, have you run `npm install` yet?\n\n");
|
||||
}
|
||||
let cwd = env::current_dir().unwrap();
|
||||
symlink_dir(&cwd.join("node_modules"), &root.join("node_modules")).unwrap();
|
||||
|
||||
// Execute webpack to generate a bundle
|
||||
let mut cmd = if cfg!(windows) {
|
||||
let mut c = Command::new("cmd");
|
||||
c.arg("/c");
|
||||
c.arg("npm");
|
||||
c
|
||||
} else {
|
||||
Command::new("npm")
|
||||
};
|
||||
cmd.arg("run").arg("run-webpack").current_dir(&root);
|
||||
run(&mut cmd, "npm");
|
||||
|
||||
let mut cmd = Command::new("node");
|
||||
cmd.args(&self.node_args);
|
||||
cmd.arg(root.join("bundle.js")).current_dir(&root);
|
||||
run(&mut cmd, "node");
|
||||
}
|
||||
|
||||
/// Reads JS generated by `wasm-bindgen` to a string.
|
||||
pub fn read_js(&self) -> String {
|
||||
let path = root().join(if self.nodejs_experimental_modules {
|
||||
"out.mjs"
|
||||
} else {
|
||||
"out.js"
|
||||
});
|
||||
println!("js, {:?}", &path);
|
||||
fs::read_to_string(path).expect("Unable to read js")
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn symlink_dir(a: &Path, b: &Path) -> io::Result<()> {
|
||||
use std::os::unix::fs::symlink;
|
||||
symlink(a, b)
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
fn symlink_dir(a: &Path, b: &Path) -> io::Result<()> {
|
||||
use std::os::windows::fs::symlink_dir;
|
||||
symlink_dir(a, b)
|
||||
}
|
||||
|
||||
fn wrap_step(desc: &str) -> WrapStep {
|
||||
println!("···················································");
|
||||
println!("{}", desc);
|
||||
WrapStep { start: Instant::now() }
|
||||
}
|
||||
|
||||
struct WrapStep { start: Instant }
|
||||
|
||||
impl Drop for WrapStep {
|
||||
fn drop(&mut self) {
|
||||
let dur = self.start.elapsed();
|
||||
println!(
|
||||
"dur: {}.{:03}s",
|
||||
dur.as_secs(),
|
||||
dur.subsec_nanos() / 1_000_000
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run(cmd: &mut Command, program: &str) {
|
||||
let _x = wrap_step(&format!("running {:?}", cmd));
|
||||
let output = match cmd.output() {
|
||||
Ok(output) => output,
|
||||
Err(err) => panic!("failed to spawn `{}`: {}", program, err),
|
||||
};
|
||||
println!("exit: {}", output.status);
|
||||
if output.stdout.len() > 0 {
|
||||
println!("stdout ---\n{}", String::from_utf8_lossy(&output.stdout));
|
||||
}
|
||||
if output.stderr.len() > 0 {
|
||||
println!("stderr ---\n{}", String::from_utf8_lossy(&output.stderr));
|
||||
}
|
||||
assert!(output.status.success());
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ fn add() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -84,7 +84,7 @@ fn string_arguments() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out";
|
||||
|
||||
@ -121,7 +121,7 @@ fn return_a_string() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
@ -168,12 +168,6 @@ fn exceptions() {
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.d.ts",
|
||||
r#"
|
||||
export function test(): void;
|
||||
"#,
|
||||
)
|
||||
.test();
|
||||
}
|
||||
|
||||
@ -197,7 +191,7 @@ fn exceptions() {
|
||||
// }
|
||||
// }
|
||||
// "#)
|
||||
// .file("test.ts", r#"
|
||||
// .file("test.js", r#"
|
||||
// import * as assert from "assert";
|
||||
// import * as wasm from "./out";
|
||||
//
|
||||
@ -223,7 +217,7 @@ fn other_exports() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out_bg";
|
||||
|
||||
@ -267,7 +261,7 @@ fn no_std() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out_bg";
|
||||
|
||||
@ -329,7 +323,7 @@ fn no_std_class() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as wasm from "./out_bg";
|
||||
|
||||
|
@ -29,12 +29,12 @@ fn export() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
function assert_arrays_equal(a: any, b: any) {
|
||||
function assert_arrays_equal(a, b) {
|
||||
console.log(a, b);
|
||||
assert.strictEqual(a.length, b.length);
|
||||
assert.strictEqual(a.byteLength, b.byteLength);
|
||||
@ -129,68 +129,68 @@ fn import() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function js_i8(a: any): any {
|
||||
export function js_i8(a) {
|
||||
assert.strictEqual(a.length, 2);
|
||||
assert.strictEqual(a[0], 1);
|
||||
assert.strictEqual(a[1], 2);
|
||||
return a;
|
||||
}
|
||||
|
||||
export function js_u8(a: any): any {
|
||||
export function js_u8(a) {
|
||||
assert.strictEqual(a.length, 2);
|
||||
assert.strictEqual(a[0], 1);
|
||||
assert.strictEqual(a[1], 2);
|
||||
return a;
|
||||
}
|
||||
|
||||
export function js_i16(a: any): any {
|
||||
export function js_i16(a) {
|
||||
assert.strictEqual(a.length, 2);
|
||||
assert.strictEqual(a[0], 1);
|
||||
assert.strictEqual(a[1], 2);
|
||||
return a;
|
||||
}
|
||||
|
||||
export function js_u16(a: any): any {
|
||||
export function js_u16(a) {
|
||||
assert.strictEqual(a.length, 2);
|
||||
assert.strictEqual(a[0], 1);
|
||||
assert.strictEqual(a[1], 2);
|
||||
return a;
|
||||
}
|
||||
|
||||
export function js_i32(a: any): any {
|
||||
export function js_i32(a) {
|
||||
assert.strictEqual(a.length, 2);
|
||||
assert.strictEqual(a[0], 1);
|
||||
assert.strictEqual(a[1], 2);
|
||||
return a;
|
||||
}
|
||||
|
||||
export function js_u32(a: any): any {
|
||||
export function js_u32(a) {
|
||||
assert.strictEqual(a.length, 2);
|
||||
assert.strictEqual(a[0], 1);
|
||||
assert.strictEqual(a[1], 2);
|
||||
return a;
|
||||
}
|
||||
|
||||
export function js_f32(a: any): any {
|
||||
export function js_f32(a) {
|
||||
assert.strictEqual(a.length, 2);
|
||||
assert.strictEqual(a[0], 1);
|
||||
assert.strictEqual(a[1], 2);
|
||||
return a;
|
||||
}
|
||||
|
||||
export function js_f64(a: any): any {
|
||||
export function js_f64(a) {
|
||||
assert.strictEqual(a.length, 2);
|
||||
assert.strictEqual(a[0], 1);
|
||||
assert.strictEqual(a[1], 2);
|
||||
return a;
|
||||
}
|
||||
|
||||
function assert_arrays_equal(a: any, b: any) {
|
||||
function assert_arrays_equal(a, b) {
|
||||
console.log(a, b);
|
||||
assert.strictEqual(a.length, b.length);
|
||||
assert.strictEqual(a.byteLength, b.byteLength);
|
||||
@ -280,9 +280,9 @@ fn pass_array_works() {
|
||||
.file(
|
||||
"test.js",
|
||||
r#"
|
||||
const wasm = require("./out");
|
||||
import * as wasm from "./out";
|
||||
|
||||
module.exports.test = function() {
|
||||
export function test() {
|
||||
wasm.rust_i8([1, 2]);
|
||||
wasm.rust_u8([1, 2]);
|
||||
wasm.rust_i16([1, 2]);
|
||||
@ -291,7 +291,7 @@ fn pass_array_works() {
|
||||
wasm.rust_u32([1, 2]);
|
||||
wasm.rust_f32([1, 2]);
|
||||
wasm.rust_f64([1, 2]);
|
||||
};
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.test();
|
||||
@ -351,12 +351,12 @@ fn import_mut() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
function foo(a: any) {
|
||||
function foo(a) {
|
||||
assert.strictEqual(a.length, 3);
|
||||
assert.strictEqual(a[0], 1);
|
||||
assert.strictEqual(a[1], 2);
|
||||
@ -412,12 +412,12 @@ fn export_mut() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
function run(a: any, rust: any) {
|
||||
function run(a, rust) {
|
||||
assert.strictEqual(a.length, 3);
|
||||
a[0] = 1;
|
||||
a[1] = 2;
|
||||
@ -496,7 +496,7 @@ fn return_vec_ok() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
@ -33,7 +33,7 @@ fn works() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
"test.js",
|
||||
r#"
|
||||
import * as assert from "assert";
|
||||
import { run } from "./out";
|
||||
|
79
tests/all/typescript.rs
Normal file
79
tests/all/typescript.rs
Normal file
@ -0,0 +1,79 @@
|
||||
use super::project;
|
||||
|
||||
#[test]
|
||||
fn works() {
|
||||
project()
|
||||
.webpack(true)
|
||||
.file(
|
||||
"src/lib.rs",
|
||||
r#"
|
||||
#![feature(proc_macro, wasm_custom_section, wasm_import_module)]
|
||||
|
||||
extern crate wasm_bindgen;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn foo() {}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn bar(a: &str, b: u32) -> String {
|
||||
format!("{} {}", a, b)
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn thunk(a: &JsValue) {
|
||||
drop(a);
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub struct A {
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
impl A {
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new() -> A {
|
||||
A {}
|
||||
}
|
||||
|
||||
pub fn new2() -> A {
|
||||
A {}
|
||||
}
|
||||
|
||||
pub fn foo(&self) {}
|
||||
|
||||
pub fn bar(&self, _a: u32) {}
|
||||
|
||||
pub fn baz(&self, _d: &A) {}
|
||||
}
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"test.ts",
|
||||
r#"
|
||||
import * as assert from 'assert';
|
||||
import { foo, bar, A, thunk } from './out';
|
||||
import { memory } from './out_bg';
|
||||
|
||||
export function test() {
|
||||
foo();
|
||||
assert.strictEqual(bar('a', 3), 'a 3');
|
||||
|
||||
const x = new A();
|
||||
x.foo();
|
||||
x.free();
|
||||
|
||||
const y = A.new2();
|
||||
y.foo();
|
||||
y.bar(2);
|
||||
y.baz(y);
|
||||
y.free();
|
||||
|
||||
thunk(memory);
|
||||
};
|
||||
"#,
|
||||
)
|
||||
.test();
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ fn method() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"foo.ts",
|
||||
"foo.js",
|
||||
r#"
|
||||
export class Foo {
|
||||
constructor(private value: number) {
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
myCmp(other: Foo): boolean {
|
||||
myCmp(other) {
|
||||
return this.value === other.value;
|
||||
}
|
||||
}
|
||||
@ -73,19 +73,19 @@ fn property() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"foo.ts",
|
||||
"foo.js",
|
||||
r#"
|
||||
export class Foo {
|
||||
constructor(private _value: number) {
|
||||
this._value = _value;
|
||||
constructor(value) {
|
||||
this._value = value;
|
||||
}
|
||||
|
||||
get value(): number {
|
||||
get value() {
|
||||
return this._value;
|
||||
}
|
||||
|
||||
set value(_value: number) {
|
||||
this._value = _value;
|
||||
set value(value) {
|
||||
this._value = value;
|
||||
}
|
||||
}
|
||||
"#,
|
||||
@ -132,17 +132,20 @@ fn named_constructor() {
|
||||
)
|
||||
.file(
|
||||
// Not a perfect test, but it gets the job done.
|
||||
"foo.ts",
|
||||
"foo.js",
|
||||
r#"
|
||||
export class Foo {
|
||||
protected _value: number = 0;
|
||||
get value(): number {
|
||||
constructor() {
|
||||
this._value = 0;
|
||||
}
|
||||
|
||||
get value(){
|
||||
return this._value;
|
||||
}
|
||||
}
|
||||
|
||||
export class Bar extends Foo {
|
||||
constructor(_value: number) {
|
||||
constructor(_value) {
|
||||
super();
|
||||
this._value = _value;
|
||||
}
|
||||
@ -185,16 +188,17 @@ fn static_method() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"foo.ts",
|
||||
"foo.js",
|
||||
r#"
|
||||
export class Foo {
|
||||
private static value: number = 0;
|
||||
static swap(value: number): number {
|
||||
static swap(value) {
|
||||
const res = Foo.value;
|
||||
Foo.value = value;
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
Foo.value = 0;
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
@ -235,19 +239,19 @@ fn static_property() {
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
"foo.ts",
|
||||
"foo.js",
|
||||
r#"
|
||||
export class Foo {
|
||||
private static _value: number = 0;
|
||||
|
||||
static get value(): number {
|
||||
static get value(){
|
||||
return Foo._value;
|
||||
}
|
||||
|
||||
static set value(_value: number) {
|
||||
Foo._value = _value;
|
||||
static set value(value) {
|
||||
Foo._value = value;
|
||||
}
|
||||
}
|
||||
|
||||
Foo._value = 0;
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
|
Reference in New Issue
Block a user