| 1 |
use pretty_assertions::assert_eq; |
| 2 |
use wit_encoder::{Include, Package, PackageName, StandaloneFunc, World}; |
| 3 |
|
| 4 |
const PACKAGE: &str = indoc::indoc! {" |
| 5 |
package foo:foo; |
| 6 |
|
| 7 |
world foo { |
| 8 |
import a: func(); |
| 9 |
} |
| 10 |
|
| 11 |
world bar { |
| 12 |
import a: func(); |
| 13 |
import b: func(); |
| 14 |
} |
| 15 |
|
| 16 |
world baz { |
| 17 |
import a: func(); |
| 18 |
import b: func(); |
| 19 |
import c: func(); |
| 20 |
} |
| 21 |
|
| 22 |
world quux { |
| 23 |
include foo with { a as b }; |
| 24 |
include bar with { a as b, b as c }; |
| 25 |
include baz with { a as b, b as c, c as d }; |
| 26 |
} |
| 27 |
"}; |
| 28 |
|
| 29 |
#[test] |
| 30 |
fn concrete_types() { |
| 31 |
let mut package = Package::new(PackageName::new("foo", "foo", None)); |
| 32 |
|
| 33 |
let mut world = World::new("foo"); |
| 34 |
world.function_import(StandaloneFunc::new("a", false)); |
| 35 |
package.world(world); |
| 36 |
|
| 37 |
let mut world = World::new("bar"); |
| 38 |
world.function_import(StandaloneFunc::new("a", false)); |
| 39 |
world.function_import(StandaloneFunc::new("b", false)); |
| 40 |
package.world(world); |
| 41 |
|
| 42 |
let mut world = World::new("baz"); |
| 43 |
world.function_import(StandaloneFunc::new("a", false)); |
| 44 |
world.function_import(StandaloneFunc::new("b", false)); |
| 45 |
world.function_import(StandaloneFunc::new("c", false)); |
| 46 |
package.world(world); |
| 47 |
|
| 48 |
let mut world = World::new("quux"); |
| 49 |
|
| 50 |
let mut include = Include::new("foo"); |
| 51 |
include.with("a", "b"); |
| 52 |
world.include(include); |
| 53 |
|
| 54 |
let mut include = Include::new("bar"); |
| 55 |
include.with("a", "b"); |
| 56 |
include.with("b", "c"); |
| 57 |
world.include(include); |
| 58 |
|
| 59 |
let mut include = Include::new("baz"); |
| 60 |
include.with("a", "b"); |
| 61 |
include.with("b", "c"); |
| 62 |
include.with("c", "d"); |
| 63 |
world.include(include); |
| 64 |
|
| 65 |
package.world(world); |
| 66 |
|
| 67 |
assert_eq!(package.to_string(), PACKAGE); |
| 68 |
} |