()
| 1902 | export impl Rect { |
| 1903 | area: (self: Rect*) -> i32 { return self.width * self.height } |
| 1904 | } |
| 1905 | "#; |
| 1906 | let mut pipeline = CompilationPipeline::new(); |
| 1907 | pipeline.set_write_artifacts(false); |
| 1908 | pipeline.set_module_resolver(Some(Box::new(move |name: &str| { |
| 1909 | (name == "geometry").then(|| provider.to_owned()) |
| 1910 | }))); |
| 1911 | |
| 1912 | let importer = r#" |
| 1913 | geometry := import("geometry") |
| 1914 | measure: <T: geometry.Measurable>(value: T*) -> i32 { return value.area() } |
| 1915 | main: () -> i32 { |
| 1916 | rect: geometry.Rect = { .width = 6, .height = 7 } |
| 1917 | return measure<geometry.Rect>(&rect) |
| 1918 | } |
| 1919 | "#; |
| 1920 | pipeline |
| 1921 | .compile_program_closure("main", importer) |
| 1922 | .expect("qualified imported interface bound should compile"); |
| 1923 | } |
| 1924 | |
| 1925 | #[test] |
| 1926 | fn imported_bounded_struct_preserves_its_interface_contract() { |
| 1927 | let provider = r#" |
| 1928 | export interface Measurable { |
| 1929 | area: (self: Self*) -> i32 |
| 1930 | } |
nothing calls this directly
no test coverage detected