File tree 3 files changed +15
-36
lines changed
3 files changed +15
-36
lines changed Original file line number Diff line number Diff line change 1
1
use super :: project;
2
2
3
- #[ test]
4
- fn unused_imports_not_generated ( ) {
5
- let mut project = project ( ) ;
6
-
7
- project
8
- . debug ( false )
9
- . file ( "src/lib.rs" , r#"
10
- #![feature(use_extern_macros)]
11
-
12
- extern crate wasm_bindgen;
13
-
14
- use wasm_bindgen::prelude::*;
15
-
16
- #[wasm_bindgen]
17
- extern {
18
- pub fn foo();
19
- }
20
-
21
- #[wasm_bindgen]
22
- pub fn run() {
23
- }
24
- "# )
25
- . file ( "test.js" , r#"
26
- import { run } from "./out";
27
-
28
- export function test() {
29
- run();
30
- }
31
- "# )
32
- . test ( ) ;
33
-
34
- let contents = project. read_js ( ) ;
35
- assert ! ( contents. contains( "run" ) , "didn't find `run` in {}" , contents) ;
36
- assert ! ( !contents. contains( "foo" ) , "found `foo` in {}" , contents) ;
37
- }
38
-
39
3
#[ test]
40
4
fn versions ( ) {
41
5
project ( )
Original file line number Diff line number Diff line change 1
1
const assert = require ( 'assert' ) ;
2
2
const wasm = require ( 'wasm-bindgen-test' ) ;
3
+ const fs = require ( 'fs' ) ;
3
4
4
5
let ARG = null ;
5
6
let ANOTHER_ARG = null ;
@@ -93,3 +94,9 @@ exports.interpret_2_as_custom_type = function() {
93
94
94
95
exports . baz$ = function ( ) { } ;
95
96
exports . $foo = 1.0 ;
97
+
98
+ exports . assert_dead_import_not_generated = function ( ) {
99
+ const filename = require . resolve ( "wasm-bindgen-test" ) ;
100
+ const bindings = fs . readFileSync ( filename ) ;
101
+ assert . ok ( ! bindings . includes ( "unused_import" ) ) ;
102
+ } ;
Original file line number Diff line number Diff line change @@ -47,6 +47,9 @@ extern {
47
47
fn renamed_with_dollar_sign ( ) ;
48
48
#[ wasm_bindgen( js_name = "$foo" ) ]
49
49
static RENAMED : JsValue ;
50
+
51
+ fn unused_import ( ) ;
52
+ fn assert_dead_import_not_generated ( ) ;
50
53
}
51
54
52
55
#[ wasm_bindgen]
@@ -168,3 +171,8 @@ fn rename_with_string() {
168
171
fn rename_static_with_string ( ) {
169
172
assert_eq ! ( RENAMED . as_f64( ) , Some ( 1.0 ) ) ;
170
173
}
174
+
175
+ #[ wasm_bindgen_test]
176
+ fn dead_imports_not_generated ( ) {
177
+ assert_dead_import_not_generated ( ) ;
178
+ }
You can’t perform that action at this time.
0 commit comments