@@ -895,4 +895,76 @@ fn reduce_right() {
895
895
"# ,
896
896
)
897
897
. test ( )
898
+ }
899
+
900
+ #[ test]
901
+ fn find_index ( ) {
902
+ project ( )
903
+ . file (
904
+ "src/lib.rs" ,
905
+ r#"
906
+ #![feature(proc_macro, wasm_custom_section)]
907
+
908
+ extern crate wasm_bindgen;
909
+ use wasm_bindgen::prelude::*;
910
+ use wasm_bindgen::js;
911
+ use JsValue;
912
+
913
+ #[wasm_bindgen]
914
+ pub fn array_find_first_even_number_index(array: &js::Array) -> u32 {
915
+ array.find_index(&mut |el, _, _| el.as_f64().unwrap() % 2. == 0., &JsValue::undefined())
916
+ }
917
+ "# ,
918
+ )
919
+ . file (
920
+ "test.js" ,
921
+ r#"
922
+ import * as assert from "assert";
923
+ import * as wasm from "./out";
924
+
925
+ export function test() {
926
+ const arrayEven = [2, 4, 6, 8];
927
+ const arrayOdd = [1, 3, 5, 7];
928
+ const arrayMixed = [3, 5, 7, 10];
929
+
930
+ assert.equal(wasm.array_find_first_even_number_index(arrayEven), 0);
931
+ assert.equal(wasm.array_find_first_even_number_index(arrayOdd), -1);
932
+ assert.equal(wasm.array_find_first_even_number_index(arrayMixed), 3);
933
+ }
934
+ "# ,
935
+ )
936
+ . test ( )
937
+ }
938
+
939
+ #[ test]
940
+ fn to_locale_string ( ) {
941
+ project ( )
942
+ . file (
943
+ "src/lib.rs" ,
944
+ r#"
945
+ #![feature(proc_macro, wasm_custom_section)]
946
+
947
+ extern crate wasm_bindgen;
948
+ use wasm_bindgen::prelude::*;
949
+ use wasm_bindgen::js;
950
+ use JsValue;
951
+
952
+ #[wasm_bindgen]
953
+ pub fn array_to_locale_string(array: &js::Array, locale: &JsValue, options: &JsValue) -> js::JsString {
954
+ array.to_locale_string(locale, options)
955
+ }
956
+ "# ,
957
+ )
958
+ . file (
959
+ "test.js" ,
960
+ r#"
961
+ import * as assert from "assert";
962
+ import * as wasm from "./out";
963
+
964
+ export function test() {
965
+ assert.equal(wasm.array_to_locale_string([1, 'a', new Date('21 Dec 1997 14:12:00 UTC')], 'en', {timeZone: 'UTC'}), '1,a,12/21/1997, 2:12:00 PM');
966
+ }
967
+ "# ,
968
+ )
969
+ . test ( )
898
970
}
0 commit comments