Commit a4402c9d authored by Kunshan Wang's avatar Kunshan Wang

WIP: tests

parent 6420c55d
package uvm.refimpl.bootimg
import uvm.refimpl.MicroVM
import uvm.refimpl.VMConf
import uvm.refimpl.UvmBundleTesterBase
import uvm.ir.textinput.ExtraMatchers
import uvm.ir.textinput.TestingBundlesValidators.MagicalOur
class TransitiveClosureTest extends UvmBundleTesterBase with ExtraMatchers {
override def makeMicroVM = new MicroVM(new VMConf())
preloadBundles("tests/uvm-refimpl-test/transitive-closure.uir")
val our = new MagicalOur(microVM.globalBundle)
behavior of "TransitiveClosureBuilder"
it should "compute transitive closure over types" in {
val tsb = new TransitiveClosureBuilder(Seq("@refi64"))(microVM)
tsb.doTransitiveClosure()
tsb.tls.set should contain(our ty "@i64")
tsb.tls.set shouldNot contain(our ty "@i32")
}
it should "compute transitive closure over function signatures" in {
val tsb = new TransitiveClosureBuilder(Seq("@s1"))(microVM)
tsb.doTransitiveClosure()
tsb.tls.set should contain(our ty "@i32")
tsb.tls.set should contain(our ty "@i16")
tsb.tls.set shouldNot contain(our ty "@i64")
}
it should "compute transitive closure over constants" in {
val tsb = new TransitiveClosureBuilder(Seq("@F", "@S"))(microVM)
tsb.doTransitiveClosure()
tsb.tls.set should contain(our const "@S0")
tsb.tls.set should contain(our const "@S1")
tsb.tls.set should contain(our const "@S2")
tsb.tls.set should contain(our ty "@i64")
tsb.tls.set should contain(our ty "@i32")
tsb.tls.set should contain(our ty "@s")
tsb.tls.set should contain(our ty "@f")
tsb.tls.set shouldNot contain(our ty "@d")
}
it should "compute transitive closure over global cells" in {
val tsb = new TransitiveClosureBuilder(Seq("@gfoo"))(microVM)
tsb.doTransitiveClosure()
tsb.tls.set should contain(our ty "@foo")
}
it should "compute transitive closure over function decls" in {
val tsb = new TransitiveClosureBuilder(Seq("@fd"))(microVM)
tsb.doTransitiveClosure()
tsb.tls.set should contain(our sig "@s1")
tsb.tls.set should contain(our ty "@i32")
tsb.tls.set should contain(our ty "@i16")
tsb.tls.set shouldNot contain(our ty "@i64")
}
it should "compute transitive closure over function defs" in {
val tsb = new TransitiveClosureBuilder(Seq("@gd"))(microVM)
tsb.doTransitiveClosure()
tsb.tls.set should contain(our sig "@s2")
tsb.tls.set should contain(our ty "@i64")
tsb.tls.set should contain(our ty "@i16")
tsb.tls.set shouldNot contain(our ty "@i32")
tsb.tls.set should contain(our const "@S0")
tsb.tls.set should contain(our const "@S1")
tsb.tls.set shouldNot contain(our const "@S2")
}
it should "compute transitive closure over exposed functions" in {
val tsb = new TransitiveClosureBuilder(Seq("@ef"))(microVM)
tsb.doTransitiveClosure()
tsb.tls.set should contain(our func "@fd")
tsb.tls.set should contain(our sig "@s1")
tsb.tls.set should contain(our ty "@i32")
tsb.tls.set should contain(our ty "@i16")
tsb.tls.set should contain(our const "@S1")
}
}
\ No newline at end of file
.typedef @i8 = int<8>
.typedef @i16 = int<16>
.typedef @i32 = int<32>
.typedef @i64 = int<64>
.typedef @f = float
.typedef @d = double
.typedef @foo = int<64>
.typedef @refi64 = ref<@i64>
.funcsig @s1 = (@i32) -> (@i16)
.const @F <@f> = 1.5f
.typedef @s = struct <@i64 @i64 @i32>
.const @S0 <@i64> = 0
.const @S1 <@i64> = 1
.const @S2 <@i32> = 2
.const @S <@s> = {@S0 @S1 @S2}
.global @gfoo <@foo>
.funcdecl @fd <@s1>
.funcsig @s2 = (@i16) -> (@i64)
.funcdef @gd VERSION %1 <@s2> {
%entry(<@i16> %x):
%b = ADD <@i64> @S0 @S1
%c = ADD <@i16> %x %x
COMMINST @uvm.thread_exit
}
.expose @ef = @fd #DEFAULT @S1
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment