mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-25 14:12:13 +00:00
Migrate rest of dependencies
test to wasm
This commit is contained in:
parent
28036db262
commit
005f7eb9fa
@ -34,6 +34,8 @@ serde_json = { version = "1.0", optional = true }
|
|||||||
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
|
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
|
||||||
wasm-bindgen-test = { path = 'crates/test', version = '=0.2.15' }
|
wasm-bindgen-test = { path = 'crates/test', version = '=0.2.15' }
|
||||||
serde_derive = "1.0"
|
serde_derive = "1.0"
|
||||||
|
wasm-bindgen-test-crate-a = { path = 'tests/crates/a' }
|
||||||
|
wasm-bindgen-test-crate-b = { path = 'tests/crates/b' }
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
|
||||||
wasm-bindgen-test-project-builder = { path = "crates/test-project-builder", version = '=0.2.15' }
|
wasm-bindgen-test-project-builder = { path = "crates/test-project-builder", version = '=0.2.15' }
|
||||||
|
@ -1,118 +0,0 @@
|
|||||||
use super::project;
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn same_api_two_crates() {
|
|
||||||
project()
|
|
||||||
.file(
|
|
||||||
"src/lib.rs",
|
|
||||||
r#"
|
|
||||||
#![feature(use_extern_macros)]
|
|
||||||
extern crate wasm_bindgen;
|
|
||||||
extern crate a;
|
|
||||||
extern crate b;
|
|
||||||
|
|
||||||
use wasm_bindgen::prelude::*;
|
|
||||||
|
|
||||||
#[wasm_bindgen(module = "./foo")]
|
|
||||||
extern {
|
|
||||||
fn assert_next_undefined();
|
|
||||||
fn assert_next_ten();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[wasm_bindgen]
|
|
||||||
pub fn test() {
|
|
||||||
assert_next_undefined();
|
|
||||||
a::test();
|
|
||||||
assert_next_ten();
|
|
||||||
b::test();
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"foo.js",
|
|
||||||
r#"
|
|
||||||
import { strictEqual } from "assert";
|
|
||||||
|
|
||||||
let next = null;
|
|
||||||
|
|
||||||
export function assert_next_undefined() {
|
|
||||||
next = undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function assert_next_ten() {
|
|
||||||
next = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function foo(a) {
|
|
||||||
console.log(a, next);
|
|
||||||
strictEqual(a, next);
|
|
||||||
next = null;
|
|
||||||
}
|
|
||||||
"#,
|
|
||||||
)
|
|
||||||
.add_local_dependency("a", "a")
|
|
||||||
.file(
|
|
||||||
"a/Cargo.toml",
|
|
||||||
&format!(r#"
|
|
||||||
[package]
|
|
||||||
name = 'a'
|
|
||||||
version = '0.0.0'
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
wasm-bindgen = {{ path = '{}' }}
|
|
||||||
"#,
|
|
||||||
env!("CARGO_MANIFEST_DIR")
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"a/src/lib.rs",
|
|
||||||
"
|
|
||||||
#![feature(use_extern_macros)]
|
|
||||||
extern crate wasm_bindgen;
|
|
||||||
|
|
||||||
use wasm_bindgen::prelude::*;
|
|
||||||
|
|
||||||
#[wasm_bindgen(module = \"./foo\")]
|
|
||||||
extern {
|
|
||||||
fn foo();
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn test() {
|
|
||||||
foo();
|
|
||||||
}
|
|
||||||
",
|
|
||||||
)
|
|
||||||
.add_local_dependency("b", "b")
|
|
||||||
.file(
|
|
||||||
"b/Cargo.toml",
|
|
||||||
&format!(r#"
|
|
||||||
[package]
|
|
||||||
name = 'b'
|
|
||||||
version = '0.0.0'
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
wasm-bindgen = {{ path = '{}' }}
|
|
||||||
"#,
|
|
||||||
env!("CARGO_MANIFEST_DIR")
|
|
||||||
),
|
|
||||||
)
|
|
||||||
.file(
|
|
||||||
"b/src/lib.rs",
|
|
||||||
"
|
|
||||||
#![feature(use_extern_macros)]
|
|
||||||
extern crate wasm_bindgen;
|
|
||||||
|
|
||||||
use wasm_bindgen::prelude::*;
|
|
||||||
|
|
||||||
#[wasm_bindgen(module = \"./foo\")]
|
|
||||||
extern {
|
|
||||||
fn foo(x: u32);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn test() {
|
|
||||||
foo(10);
|
|
||||||
}
|
|
||||||
",
|
|
||||||
)
|
|
||||||
.test();
|
|
||||||
}
|
|
@ -5,7 +5,6 @@ extern crate wasm_bindgen_test_project_builder as project_builder;
|
|||||||
use project_builder::project;
|
use project_builder::project;
|
||||||
|
|
||||||
mod comments;
|
mod comments;
|
||||||
mod dependencies;
|
|
||||||
mod js_objects;
|
mod js_objects;
|
||||||
mod imports;
|
mod imports;
|
||||||
mod simple;
|
mod simple;
|
||||||
|
9
tests/crates/a/Cargo.toml
Normal file
9
tests/crates/a/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[package]
|
||||||
|
name = "wasm-bindgen-test-crate-a"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["The wasm-bindgen Authors"]
|
||||||
|
license = "MIT/Apache-2.0"
|
||||||
|
description = "internal test crate for wasm-bindgen"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wasm-bindgen = { path = '../../..', version = '0.2' }
|
14
tests/crates/a/src/lib.rs
Normal file
14
tests/crates/a/src/lib.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#![feature(use_extern_macros)]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen;
|
||||||
|
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
#[wasm_bindgen(module = "tests/wasm/duplicate_deps.js", version = "*")]
|
||||||
|
extern {
|
||||||
|
fn foo();
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn test() {
|
||||||
|
foo();
|
||||||
|
}
|
9
tests/crates/b/Cargo.toml
Normal file
9
tests/crates/b/Cargo.toml
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
[package]
|
||||||
|
name = "wasm-bindgen-test-crate-b"
|
||||||
|
version = "0.1.0"
|
||||||
|
authors = ["The wasm-bindgen Authors"]
|
||||||
|
license = "MIT/Apache-2.0"
|
||||||
|
description = "internal test crate for wasm-bindgen"
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wasm-bindgen = { path = '../../..', version = '0.2' }
|
14
tests/crates/b/src/lib.rs
Normal file
14
tests/crates/b/src/lib.rs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#![feature(use_extern_macros)]
|
||||||
|
|
||||||
|
extern crate wasm_bindgen;
|
||||||
|
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
#[wasm_bindgen(module = "tests/wasm/duplicate_deps.js", version = "*")]
|
||||||
|
extern {
|
||||||
|
fn foo(x: u32);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn test() {
|
||||||
|
foo(10);
|
||||||
|
}
|
17
tests/wasm/duplicate_deps.js
Normal file
17
tests/wasm/duplicate_deps.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
const assert = require('assert');
|
||||||
|
|
||||||
|
let next = null;
|
||||||
|
|
||||||
|
exports.assert_next_undefined = function() {
|
||||||
|
next = undefined;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.assert_next_ten = function() {
|
||||||
|
next = 10;
|
||||||
|
};
|
||||||
|
|
||||||
|
exports.foo = function(a) {
|
||||||
|
console.log(a, next);
|
||||||
|
assert.strictEqual(a, next);
|
||||||
|
next = null;
|
||||||
|
};
|
18
tests/wasm/duplicate_deps.rs
Normal file
18
tests/wasm/duplicate_deps.rs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
use wasm_bindgen_test::*;
|
||||||
|
use wasm_bindgen_test_crate_a as a;
|
||||||
|
use wasm_bindgen_test_crate_b as b;
|
||||||
|
|
||||||
|
#[wasm_bindgen(module = "tests/wasm/duplicate_deps.js", version = "*")]
|
||||||
|
extern {
|
||||||
|
fn assert_next_undefined();
|
||||||
|
fn assert_next_ten();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen_test]
|
||||||
|
fn works() {
|
||||||
|
assert_next_undefined();
|
||||||
|
a::test();
|
||||||
|
assert_next_ten();
|
||||||
|
b::test();
|
||||||
|
}
|
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
extern crate wasm_bindgen_test;
|
extern crate wasm_bindgen_test;
|
||||||
extern crate wasm_bindgen;
|
extern crate wasm_bindgen;
|
||||||
|
extern crate wasm_bindgen_test_crate_a;
|
||||||
|
extern crate wasm_bindgen_test_crate_b;
|
||||||
|
|
||||||
#[cfg(feature = "serde-serialize")]
|
#[cfg(feature = "serde-serialize")]
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
@ -12,10 +14,11 @@ pub mod api;
|
|||||||
pub mod char;
|
pub mod char;
|
||||||
pub mod classes;
|
pub mod classes;
|
||||||
pub mod closures;
|
pub mod closures;
|
||||||
|
pub mod duplicate_deps;
|
||||||
pub mod duplicates;
|
pub mod duplicates;
|
||||||
pub mod enums;
|
pub mod enums;
|
||||||
pub mod imports;
|
|
||||||
pub mod import_class;
|
pub mod import_class;
|
||||||
|
pub mod imports;
|
||||||
pub mod js_objects;
|
pub mod js_objects;
|
||||||
pub mod math;
|
pub mod math;
|
||||||
pub mod node;
|
pub mod node;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user