更新libclamav库1.0.0版本

This commit is contained in:
2023-01-14 18:28:39 +08:00
parent b879ee0b2e
commit 45fe15f472
8531 changed files with 1222046 additions and 177272 deletions

View File

@@ -0,0 +1,20 @@
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
// This test is in the headless suite so that we can test the `externref` table
// implementation of `externref_heap_live_count` (as opposed to the JS `heap`
// implementation) in Firefox.
#[wasm_bindgen_test]
fn test_externref_heap_live_count() {
let initial = wasm_bindgen::externref_heap_live_count();
let after_alloc = {
let _vals: Vec<_> = (0..10).map(JsValue::from).collect();
wasm_bindgen::externref_heap_live_count()
};
let after_dealloc = wasm_bindgen::externref_heap_live_count();
assert_eq!(initial, after_dealloc);
assert_eq!(initial + 10, after_alloc);
}

View File

@@ -0,0 +1,2 @@
export function import_export_same_name() {
}

View File

@@ -0,0 +1,61 @@
#![cfg(target_arch = "wasm32")]
extern crate wasm_bindgen;
extern crate wasm_bindgen_test;
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
wasm_bindgen_test_configure!(run_in_browser);
#[wasm_bindgen]
pub struct ConsumeRetString;
#[wasm_bindgen]
impl ConsumeRetString {
// https://github.com/rustwasm/wasm-bindgen/issues/329#issuecomment-411082013
//
// This used to cause two `const ptr = ...` declarations, which is invalid
// JS.
pub fn consume(self) -> String {
String::new()
}
}
#[wasm_bindgen_test]
fn works() {
ConsumeRetString.consume();
}
#[wasm_bindgen]
extern "C" {
#[wasm_bindgen(js_namespace = console)]
pub fn log(s: &str);
}
#[wasm_bindgen_test]
fn can_log_html_strings() {
log("<script>alert('lol')</script>");
}
#[wasm_bindgen]
pub fn import_export_same_name() {
#[wasm_bindgen(module = "/tests/headless/main.js")]
extern "C" {
fn import_export_same_name();
}
import_export_same_name();
}
pub mod externref_heap_live_count;
pub mod modules;
pub mod snippets;
pub mod strings;
#[wasm_bindgen_test]
fn closures_work() {
let x = Closure::wrap(Box::new(|| {}) as Box<dyn FnMut()>);
drop(x);
let x = Closure::wrap(Box::new(|| {}) as Box<dyn FnMut()>);
x.forget();
}

View File

@@ -0,0 +1,3 @@
export function get_five() {
return 5;
}

View File

@@ -0,0 +1,12 @@
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
#[wasm_bindgen(raw_module = "./tests/headless/modules.js")]
extern "C" {
fn get_five() -> u32;
}
#[wasm_bindgen_test]
fn test_get_five() {
assert_eq!(get_five(), 5);
}

View File

@@ -0,0 +1,58 @@
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
#[wasm_bindgen(module = "/tests/headless/snippets1.js")]
extern "C" {
fn get_two() -> u32;
#[wasm_bindgen(js_name = get_stateful)]
fn get_stateful1() -> u32;
}
#[wasm_bindgen(module = "/tests/headless/snippets1.js")]
extern "C" {
#[wasm_bindgen(js_name = get_stateful)]
fn get_stateful2() -> u32;
}
#[wasm_bindgen_test]
fn test_get_two() {
assert_eq!(get_two(), 2);
}
#[wasm_bindgen_test]
fn stateful_deduplicated() {
assert_eq!(get_stateful1(), 1);
assert_eq!(get_stateful2(), 2);
assert_eq!(get_stateful1(), 3);
assert_eq!(get_stateful2(), 4);
}
#[wasm_bindgen(inline_js = "export function get_three() { return 3; }")]
extern "C" {
fn get_three() -> u32;
}
#[wasm_bindgen_test]
fn test_get_three() {
assert_eq!(get_three(), 3);
}
#[wasm_bindgen(inline_js = "let a = 0; export function get() { a += 1; return a; }")]
extern "C" {
#[wasm_bindgen(js_name = get)]
fn duplicate1() -> u32;
}
#[wasm_bindgen(inline_js = "let a = 0; export function get() { a += 1; return a; }")]
extern "C" {
#[wasm_bindgen(js_name = get)]
fn duplicate2() -> u32;
}
#[wasm_bindgen_test]
fn duplicate_inline_not_unified() {
assert_eq!(duplicate1(), 1);
assert_eq!(duplicate2(), 1);
assert_eq!(duplicate1(), 2);
assert_eq!(duplicate2(), 2);
}

View File

@@ -0,0 +1,9 @@
export function get_two() {
return 2;
}
let a = 0;
export function get_stateful() {
a += 1;
return a;
}

View File

@@ -0,0 +1,21 @@
export function test_string_roundtrip(f) {
const test = expected => {
const actual = f(expected);
if (actual === expected)
return;
throw new Error(`string roundtrip "${actual}" != "${expected}"`);
};
test('');
test('a');
test('💖');
test('a longer string');
test('a longer 💖 string');
test('\uFEFFbar');
}
export function identity(s) {
return s;
}

View File

@@ -0,0 +1,16 @@
use wasm_bindgen::prelude::*;
use wasm_bindgen_test::*;
#[wasm_bindgen(module = "/tests/headless/strings.js")]
extern "C" {
fn test_string_roundtrip(c: &Closure<dyn Fn(String) -> String>);
fn identity(s: &str) -> String;
}
#[wasm_bindgen_test]
fn string_roundtrip() {
test_string_roundtrip(&Closure::wrap(Box::new(|s| s)));
assert_eq!("\u{feff}bar", &identity("\u{feff}bar"));
}