Skip to content

Commit bf750ef

Browse files
committed
Disallow duplicate types in a context.
1 parent aa577bf commit bf750ef

File tree

1 file changed

+18
-20
lines changed

1 file changed

+18
-20
lines changed

test/core.jl

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,22 @@ Context() do ctx
186186
@test context(typ) == ctx
187187
end
188188

189+
# type iteration
190+
Context() do ctx
191+
st = LLVM.StructType("SomeType", ctx)
192+
193+
let ts = types(ctx)
194+
@test keytype(ts) == String
195+
@test valtype(ts) == LLVMType
196+
197+
@test haskey(ts, "SomeType")
198+
@test ts["SomeType"] == st
199+
200+
@test !haskey(ts, "SomeOtherType")
201+
@test_throws KeyError ts["SomeOtherType"]
202+
end
203+
end
204+
189205
end
190206

191207

@@ -450,6 +466,8 @@ Context() do ctx
450466
ConstantFP(LLVM.HalfType(ctx), -2.5)
451467
]
452468
@test collect(operands(constant_struct)) == expected_operands
469+
470+
@test_throws ArgumentError ConstantStruct(test_struct, ctx; anonymous=false)
453471
end
454472

455473
end
@@ -652,26 +670,6 @@ LLVM.Module("SomeModule", ctx) do mod
652670
end
653671
end
654672

655-
# type iteration
656-
Context() do ctx
657-
LLVM.Module("SomeModule", ctx) do mod
658-
st = LLVM.StructType("SomeType", ctx)
659-
ft = LLVM.FunctionType(st, [st])
660-
fn = LLVM.Function(mod, "SomeFunction", ft)
661-
662-
let ts = types(mod)
663-
@test keytype(ts) == String
664-
@test valtype(ts) == LLVMType
665-
666-
@test haskey(ts, "SomeType")
667-
@test ts["SomeType"] == st
668-
669-
@test !haskey(ts, "SomeOtherType")
670-
@test_throws KeyError ts["SomeOtherType"]
671-
end
672-
end
673-
end
674-
675673
# metadata iteration
676674
Context() do ctx
677675
LLVM.Module("SomeModule", ctx) do mod

0 commit comments

Comments
 (0)