Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mu-impl-ref2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
5
Issues
5
List
Boards
Labels
Milestones
Merge Requests
2
Merge Requests
2
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mu
mu-impl-ref2
Commits
2d453cba
Commit
2d453cba
authored
Jul 31, 2014
by
Kunshan Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate the parsed types.uir.
parent
ae0e5d1f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
130 additions
and
7 deletions
+130
-7
src/test/scala/uvm/ir/textinput/AbstractReaderSpec.scala
src/test/scala/uvm/ir/textinput/AbstractReaderSpec.scala
+6
-4
src/test/scala/uvm/ir/textinput/ExtraMatchers.scala
src/test/scala/uvm/ir/textinput/ExtraMatchers.scala
+22
-0
src/test/scala/uvm/ir/textinput/TestingBundlesValidators.scala
...est/scala/uvm/ir/textinput/TestingBundlesValidators.scala
+102
-3
No files found.
src/test/scala/uvm/ir/textinput/AbstractReaderSpec.scala
View file @
2d453cba
...
...
@@ -3,16 +3,18 @@ package uvm.ir.textinput
import
org.scalatest._
import
uvm._
trait
AbstractReaderSpec
extends
FlatSpec
with
Matchers
{
trait
AbstractReaderSpec
extends
FlatSpec
with
Matchers
with
TestingBundlesValidators
{
def
parseFile
(
fileName
:
String
)
:
Bundle
def
theSubject
:
String
behavior
of
theSubject
it
should
"read simple type definitions"
in
{
val
b
=
parseFile
(
"tests/uvm-parsing-test/types.uir"
)
validateTypes
(
b
)
}
it
should
"read simple constant definitions"
in
{
val
b
=
parseFile
(
"tests/uvm-parsing-test/constants.uir"
)
...
...
src/test/scala/uvm/ir/textinput/ExtraMatchers.scala
0 → 100644
View file @
2d453cba
package
uvm.ir.textinput
import
scala.reflect._
import
org.scalatest._
trait
ExtraMatchers
extends
Assertions
with
Matchers
{
implicit
class
AnythingExtraMatchers
(
val
thing
:
Any
)
{
def
shouldBeA
[
T:
ClassTag
](
f
:
T
=>
Unit
)
:
Unit
=
{
val
ct
=
classTag
[
T
]
if
(!
ct
.
runtimeClass
.
isAssignableFrom
(
thing
.
getClass
))
{
fail
(
"%s is not an instance of %s"
.
format
(
thing
.
getClass
,
ct
.
runtimeClass
))
}
f
(
thing
.
asInstanceOf
[
T
])
}
}
val
thatsIt
=
{
f
:
Any
=>
}
}
object
ExtraMatchers
extends
ExtraMatchers
{
}
\ No newline at end of file
src/test/scala/uvm/ir/textinput/TestingBundlesValidators.scala
View file @
2d453cba
package
uvm.ir.textinput
trait
TestingBundlesValidators
{
def
validateTypes
{
import
org.scalatest._
import
uvm._
import
uvm.types._
import
uvm.ssavalues._
import
uvm.ifuncs._
trait
TestingBundlesValidators
extends
Matchers
with
ExtraMatchers
{
implicit
class
MagicalOur
(
b
:
Bundle
)
{
def
ty
=
b
.
typeNs
def
const
=
b
.
globalValueNS
def
globalValue
=
b
.
globalValueNS
def
sig
=
b
.
funcSigNs
def
func
=
b
.
funcNs
}
def
validateTypes
(
bundle
:
Bundle
)
{
val
our
=
bundle
our
ty
"@i1"
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
1
}
our
ty
"@i8"
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
8
}
our
ty
"@i16"
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
16
}
our
ty
"@i32"
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
32
}
our
ty
"@i64"
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
64
}
our
ty
"@f"
shouldBeA
[
TypeFloat
]
thatsIt
our
ty
"@d"
shouldBeA
[
TypeDouble
]
thatsIt
our
ty
"@rv"
shouldBeA
[
TypeRef
]
{
_
.
ty
shouldBeA
[
TypeVoid
]
thatsIt
}
our
ty
"@irv"
shouldBeA
[
TypeIRef
]
{
_
.
ty
shouldBeA
[
TypeVoid
]
thatsIt
}
our
ty
"@wrv"
shouldBeA
[
TypeWeakRef
]
{
_
.
ty
shouldBeA
[
TypeVoid
]
thatsIt
}
our
ty
"@ri16"
shouldBeA
[
TypeRef
]
{
_
.
ty
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
16
}}
our
ty
"@ri16_2"
shouldBeA
[
TypeRef
]
{
_
.
ty
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
16
}}
our
ty
"@s0"
shouldBeA
[
TypeStruct
]
{
_
.
fieldTy
shouldBe
empty
}
our
ty
"@s1"
shouldBeA
[
TypeStruct
]
{
its
=>
its
fieldTy
0
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
8
}
its
fieldTy
1
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
16
}
its
fieldTy
2
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
32
}
its
fieldTy
3
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
64
}
its
fieldTy
4
shouldBeA
[
TypeFloat
]
thatsIt
its
fieldTy
5
shouldBeA
[
TypeDouble
]
thatsIt
its
fieldTy
6
shouldBeA
[
TypeRef
]
{
_
.
ty
shouldBeA
[
TypeVoid
]
thatsIt
}
its
fieldTy
7
shouldBeA
[
TypeIRef
]
{
_
.
ty
shouldBeA
[
TypeVoid
]
thatsIt
}
its
fieldTy
8
shouldBeA
[
TypeWeakRef
]
{
_
.
ty
shouldBeA
[
TypeVoid
]
thatsIt
}
its
fieldTy
9
shouldBeA
[
TypeRef
]
{
_
.
ty
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
16
}}
its
fieldTy
10
shouldBeA
[
TypeRef
]
{
_
.
ty
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
16
}}
}
our
ty
"@cons"
shouldBeA
[
TypeStruct
]
{
its
=>
its
fieldTy
0
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
64
}
its
fieldTy
1
shouldBeA
[
TypeRef
]
{
_
.
ty
shouldBe
(
our
ty
"@cons"
)}
}
our
ty
"@a0"
shouldBeA
[
TypeArray
]
{
its
=>
its
.
elemTy
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
8
}
its
.
len
shouldEqual
100
}
our
ty
"@a1"
shouldBeA
[
TypeArray
]
{
its
=>
its
.
elemTy
shouldBeA
[
TypeStruct
]
{
whose
=>
whose
fieldTy
0
shouldBeA
[
TypeDouble
]
thatsIt
whose
fieldTy
1
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
64
}
}
its
.
len
shouldEqual
10
}
our
ty
"@a2"
shouldBeA
[
TypeArray
]
{
its
=>
its
.
elemTy
shouldBe
(
our
ty
"@a1"
)
its
.
len
shouldEqual
10
}
our
ty
"@h0"
shouldBeA
[
TypeHybrid
]
{
its
=>
its
.
fixedPart
shouldBeA
[
TypeVoid
]
thatsIt
its
.
varPart
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
8
}
}
our
ty
"@h1"
shouldBeA
[
TypeHybrid
]
{
its
=>
its
.
fixedPart
shouldBeA
[
TypeStruct
]
{
whose
=>
whose
fieldTy
0
shouldBe
(
our
ty
"@i32"
)
whose
fieldTy
1
shouldBe
(
our
ty
"@i32"
)
whose
fieldTy
2
shouldBeA
[
TypeFloat
]
thatsIt
}
its
.
varPart
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
64
}
}
our
ty
"@v"
shouldBeA
[
TypeVoid
]
thatsIt
our
ty
"@f0"
shouldBeA
[
TypeFunc
]
{
its
=>
its
.
sig
.
retTy
shouldBeA
[
TypeVoid
]
thatsIt
its
.
sig
.
paramTy
shouldBe
empty
}
our
ty
"@f1"
shouldBeA
[
TypeFunc
]
{
its
=>
its
.
sig
.
retTy
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
32
}
its
.
sig
.
paramTy
(
0
)
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
32
}
its
.
sig
.
paramTy
(
1
)
shouldBeA
[
TypeIRef
]
{
_
.
ty
shouldBeA
[
TypeIRef
]
{
_
.
ty
shouldBeA
[
TypeInt
]
{
_
.
length
shouldEqual
8
}}
}
}
our
ty
"@th"
shouldBeA
[
TypeThread
]
thatsIt
our
ty
"@st"
shouldBeA
[
TypeStack
]
thatsIt
our
ty
"@tr64"
shouldBeA
[
TypeTagRef64
]
thatsIt
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment