Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ORNL Quantum Computing Institute
xacc
Commits
520fc16b
Commit
520fc16b
authored
Aug 17, 2021
by
Nguyen, Thien Minh
Browse files
Added test for IfStmt translate
Signed-off-by:
Thien Nguyen
<
nguyentm@ornl.gov
>
parent
d72952c2
Changes
1
Hide whitespace changes
Inline
Side-by-side
quantum/plugins/staq/compiler/tests/StaqCompilerTester.in.cpp
View file @
520fc16b
...
@@ -246,6 +246,31 @@ TEST(StaqCompilerTester, checkFloatingPointFormat) {
...
@@ -246,6 +246,31 @@ TEST(StaqCompilerTester, checkFloatingPointFormat) {
EXPECT_NEAR
(
rxInst
->
getParameter
(
0
).
as
<
double
>
(),
2.5e-07
,
1e-12
);
EXPECT_NEAR
(
rxInst
->
getParameter
(
0
).
as
<
double
>
(),
2.5e-07
,
1e-12
);
}
}
TEST
(
StaqCompilerTester
,
checkIfStatementTranslate
)
{
auto
xasmCompiler
=
xacc
::
getCompiler
(
"xasm"
);
auto
ir
=
xasmCompiler
->
compile
(
R"(__qpu__ void test(qbit q) {
Measure(q[0], c[0]);
if(c[0]) {
Rz(q[0], -pi/2);
}
H(q[0]);
Measure(q[0], c[1]);
CPhase(q[0], q[1], -5*pi/8);
if(c[0]) {
Rz(q[0], -pi/4);
}
if(c[1]) {
Rz(q[0], -pi/2);
}
})"
,
nullptr
);
auto
staq_compiler
=
xacc
::
getCompiler
(
"staq"
);
auto
qasm
=
staq_compiler
->
translate
(
ir
->
getComposites
()[
0
]);
std
::
cout
<<
"HOWDY:
\n
"
<<
qasm
<<
"
\n
"
;
// Check that If statements are translated.
EXPECT_TRUE
(
qasm
.
find
(
"if (c[0] == 1) rz"
)
!=
std
::
string
::
npos
);
EXPECT_TRUE
(
qasm
.
find
(
"if (c[1] == 1) rz"
)
!=
std
::
string
::
npos
);
}
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
xacc
::
Initialize
(
argc
,
argv
);
xacc
::
Initialize
(
argc
,
argv
);
xacc
::
set_verbose
(
true
);
xacc
::
set_verbose
(
true
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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