Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Shen, Siran
wacc
Commits
b6e801ce
Commit
b6e801ce
authored
Mar 19, 2021
by
Tom Zhao
Browse files
xz1919: updated struct test cases with new grammar rule for struct creation
parent
01e6cfff
Changes
13
Hide whitespace changes
Inline
Side-by-side
src/test/custom/invalid/struct/structElemCountWrong.wacc
View file @
b6e801ce
...
...
@@ -5,5 +5,5 @@
begin
struct a is {int i, char j}
a x = new a
{1}
a x = new a
(1)
end
\ No newline at end of file
src/test/custom/invalid/struct/structElemTypeWrong.wacc
View file @
b6e801ce
...
...
@@ -5,5 +5,5 @@
begin
struct a is {int i}
a x = new a
{
'a'
}
a x = new a
(
'a'
)
end
\ No newline at end of file
src/test/custom/invalid/struct/structElemUndelcare.wacc
View file @
b6e801ce
...
...
@@ -5,6 +5,6 @@
begin
struct a is {int b}
a x = new a
{1}
;
a x = new a
(1)
;
println a.c
end
\ No newline at end of file
src/test/custom/invalid/struct/structNoElem.wacc
View file @
b6e801ce
...
...
@@ -5,5 +5,5 @@
begin
struct a is {int i}
a x = new a
{}
a x = new a
()
end
\ No newline at end of file
src/test/custom/invalid/struct/structNull.wacc
View file @
b6e801ce
...
...
@@ -6,7 +6,7 @@
begin
struct a is {b b}
struct b is {int i}
a a = new a
{
null
}
;
a.b = new b
{1}
;
a a = new a
(
null
)
;
a.b = new b
(1)
;
println a.b.i
end
\ No newline at end of file
src/test/custom/invalid/struct/structUndeclare.wacc
View file @
b6e801ce
...
...
@@ -4,5 +4,5 @@
# Program:
begin
a x = new a
{}
a x = new a
()
end
\ No newline at end of file
src/test/custom/valid/struct/structEmpty.wacc
View file @
b6e801ce
...
...
@@ -7,7 +7,7 @@ begin
struct a is {b b}
struct b is {int i}
a a = empty;
a = new a
{
empty
}
;
a.b = new b
{1}
;
a = new a
(
empty
)
;
a.b = new b
(1)
;
println a.b.i
end
\ No newline at end of file
src/test/custom/valid/struct/structFree.wacc
View file @
b6e801ce
...
...
@@ -5,6 +5,6 @@
begin
struct a is {int i}
a x = new a
{
10
}
;
a x = new a
(
10
)
;
free x
end
\ No newline at end of file
src/test/custom/valid/struct/structNested.wacc
View file @
b6e801ce
...
...
@@ -9,7 +9,7 @@
begin
struct a is {int i, b b}
struct b is {int j, a a}
a a = new a
{
1, new b
{
2, empty
}}
;
a a = new a
(
1, new b
(
2, empty
))
;
a.b.a = a;
println a.i;
println a.b.j;
...
...
src/test/custom/valid/struct/structRead.wacc
View file @
b6e801ce
...
...
@@ -6,7 +6,7 @@
begin
struct a is {int i}
a x = new a
{0}
;
a x = new a
(0)
;
read x.i;
println x.i
end
\ No newline at end of file
src/test/custom/valid/struct/structRecursive.wacc
View file @
b6e801ce
...
...
@@ -6,12 +6,12 @@
begin
struct node is {int i, node next}
int count = 0;
node start = new node
{
count, empty
}
;
node start = new node
(
count, empty
)
;
node cur = start;
count = count + 1;
while count <= 10 do
cur.next = new node
{
count, empty
}
;
cur.next = new node
(
count, empty
)
;
cur = cur.next;
count = count + 1
done;
...
...
src/test/custom/valid/struct/structSimple.wacc
View file @
b6e801ce
...
...
@@ -5,6 +5,6 @@
begin
struct a is {int value}
a x = new a
{1}
;
a x = new a
(1)
;
println x.value
end
\ No newline at end of file
src/test/custom/valid/struct/structWithFunc.wacc
View file @
b6e801ce
...
...
@@ -6,9 +6,9 @@
begin
struct a is {int b}
a a(int b) is return new a
{b}
end
a a(int b) is return new a
(b)
end
struct b is {int c}
b b(int c) is return new b
{c}
end
b b(int c) is return new b
(c)
end
a x = call a(1);
println x.b;
b y = call b(2);
...
...
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