A lightweight WebAssembly runtime that is fast, secure, and standards-compliant
Add validation tests for component model map key types (#14841)
Randolf J.bdd4ae9b487d
diff --git a/tests/misc_testsuite/component-model/map-disabled.wast b/tests/misc_testsuite/component-model/map-disabled.wastnew file mode 100644index 0000000000..ce82892d5c--- /dev/null+++ b/tests/misc_testsuite/component-model/map-disabled.wast@@ -0,0 +1,5 @@+;;! component_model_map = false++(assert_invalid+ (component (type (map u32 string)))+ "Maps require the component model map feature")diff --git a/tests/misc_testsuite/component-model/map-types.wast b/tests/misc_testsuite/component-model/map-types.wastindex 74f4f34ac1..9a821110a0 100644--- a/tests/misc_testsuite/component-model/map-types.wast+++ b/tests/misc_testsuite/component-model/map-types.wast@@ -6,3 +6,57 @@(type (map u32 u32))(type (map string (map u32 string))))++;; Every type in the `keytype` grammar can be used as a map key.+(component+ (type (map bool u32))+ (type (map s8 u32))+ (type (map u8 u32))+ (type (map s16 u32))+ (type (map u16 u32))+ (type (map s32 u32))+ (type (map u32 u32))+ (type (map s64 u32))+ (type (map u64 u32))+ (type (map char u32))+ (type (map string u32))+)++;; Any other type is rejected as a map key.+(assert_invalid+ (component (type (map f32 u32)))+ "invalid map key type")++(assert_invalid+ (component (type (map f64 u32)))+ "invalid map key type")++(assert_invalid+ (component (type (map (list u32) u32)))+ "invalid map key type")++(assert_invalid+ (component+ (type $r (record (field "a" u32)))+ (type (map $r u32)))+ "invalid map key type")++(assert_invalid+ (component (type (map (option u32) u32)))+ "invalid map key type")++(assert_invalid+ (component (type (map (tuple u32 u32) u32)))+ "invalid map key type")++(assert_invalid+ (component+ (type $t (resource (rep i32)))+ (type (map (own $t) u32)))+ "invalid map key type")++(assert_invalid+ (component+ (type $t (resource (rep i32)))+ (type (map (borrow $t) u32)))+ "invalid map key type")