-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing a bug in if-then-else, adding test cases (#342)
* adding simple setter-getter example for testing implementation of new * adding an example that combines a bunch of things * working towards fixing #340 * this may clear up #340, pushing to run against travis * typo * whitespace in test runner output * whitespace in test files * adding two tests. MultiLineIfRetSm.obs works now and shows me that the fixs i made last friday in 38e8ec0 and 2aea8fc at least don't break just by having more than one line in the if-block, which is good. MultiLineIfRet.obs does not work, per #341 * removing some comments, dead code * inlining a simple function twice * removing tabs and making the indentation uniform for obsidian files in ganache test * updating file names * fixing english langauge typo * comments in tests
- Loading branch information
Showing
33 changed files
with
250 additions
and
147 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
main contract BoolLiteral{ | ||
transaction BoolLiteral () { | ||
bool x; | ||
x = true; | ||
x = false; | ||
} | ||
transaction BoolLiteral () { | ||
bool x; | ||
x = true; | ||
x = false; | ||
} | ||
|
||
transaction main() returns bool { | ||
transaction main() returns bool { | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"gas" : 30000000000, | ||
"gasprice" : "0x9184e72a000", | ||
"startingeth" : 500000000, | ||
"numaccts" : 1, | ||
"testexp" : "main()", | ||
"expected" : "24" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* this test combines the features of the other smaller tests that all come | ||
* conceptually prior to structure types into one file, showing that they | ||
* still work when they also interact. | ||
*/ | ||
|
||
main contract CombinedBasics { | ||
transaction val() returns int { | ||
int x = 70; | ||
if ( true && ! false ) { | ||
x = 4 + 20; | ||
} else { | ||
x = 13; | ||
} | ||
return x; | ||
} | ||
transaction main() returns int{ | ||
int x; | ||
x = 9 + 0; | ||
x = val(); | ||
return x; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"gas" : 30000000000, | ||
"gasprice" : "0x9184e72a000", | ||
"startingeth" : 500000000, | ||
"numaccts" : 1, | ||
"testexp" : "main()", | ||
"expected" : "24" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* this test shows the same amount of compositionality of the simple | ||
* language features as CombinedBasics, but also with multiple exit points | ||
* from different branches of an if-then-else. | ||
*/ | ||
|
||
main contract CombinedBasicsRet { | ||
transaction val() returns int { | ||
if ( true && ! false ) { | ||
return 4 + 20; | ||
} else { | ||
return 13; | ||
} | ||
} | ||
transaction main() returns int{ | ||
int x; | ||
x = 9 + 0; | ||
x = val(); | ||
return x; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
main contract If { | ||
transaction iftest() { | ||
int x; | ||
if (true) { | ||
x = 1; | ||
} | ||
return; | ||
transaction iftest() { | ||
int x; | ||
if (true) { | ||
x = 1; | ||
} | ||
return; | ||
} | ||
|
||
transaction main() returns int { | ||
int x = 0; | ||
if (true) { | ||
x = 1; | ||
} | ||
return x; | ||
transaction main() returns int { | ||
int x = 0; | ||
if (true) { | ||
x = 1; | ||
} | ||
return x; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
main contract IfThenElse { | ||
transaction ifthenelse() { | ||
int x; | ||
if (true) { | ||
x = 1; | ||
} else { | ||
x = 0; | ||
} | ||
return; | ||
transaction ifthenelse() { | ||
int x; | ||
if (true) { | ||
x = 1; | ||
} else { | ||
x = 0; | ||
} | ||
return; | ||
} | ||
|
||
transaction main() returns int { | ||
int x = 9; | ||
if (false) { | ||
x = 50; | ||
} else { | ||
x = 90; | ||
} | ||
return x; | ||
transaction main() returns int { | ||
int x = 9; | ||
if (false) { | ||
x = 50; | ||
} else { | ||
x = 90; | ||
} | ||
return x; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
main contract IntConst{ | ||
transaction intconst() { | ||
int x; | ||
x = 12; | ||
return; | ||
} | ||
transaction intconst() { | ||
int x; | ||
x = 12; | ||
return; | ||
} | ||
|
||
transaction main() returns int { | ||
return 12; | ||
} | ||
transaction main() returns int { | ||
return 12; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
main contract MultiLineIfRet { | ||
transaction val() returns int { | ||
int x = 0; | ||
if ( true && ! false ) { | ||
x = 4+20; | ||
x = 11; | ||
return 4 + x; | ||
} else { | ||
x = 13; | ||
x = 90; | ||
return 13; | ||
} | ||
} | ||
transaction main() returns int{ | ||
int x; | ||
x = 9 + 0; | ||
x = val(); | ||
return x; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"gas" : 30000000000, | ||
"gasprice" : "0x9184e72a000", | ||
"startingeth" : 500000000, | ||
"numaccts" : 1, | ||
"testexp" : "main()", | ||
"expected" : "24" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* this test demonstrates that if-then-else blocks can have more than one | ||
* line in them and still function correctly; it stops short of having much | ||
* more than 1 line because of a limit on the number of stack | ||
* variables. (https://github.com/mcoblenz/Obsidian/issues/341) | ||
*/ | ||
|
||
main contract MultiLineIfRetSm { | ||
transaction val() returns int { | ||
int x = 0; | ||
if ( true && ! false ) { | ||
x = 20; | ||
return 4 + x; | ||
} else { | ||
return 13; | ||
} | ||
} | ||
transaction main() returns int{ | ||
int x; | ||
x = 9 + 0; | ||
x = val(); | ||
return x; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsAdd{ | ||
transaction primopsadd() returns int { | ||
return(5+8); | ||
} | ||
transaction primopsadd() returns int { | ||
return(5+8); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsAnd{ | ||
transaction primopsand() returns bool { | ||
return(true && false); | ||
} | ||
transaction primopsand() returns bool { | ||
return(true && false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsDiv{ | ||
transaction primopsdiv() returns int { | ||
return(4/2); | ||
} | ||
transaction primopsdiv() returns int { | ||
return(4/2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsEq{ | ||
transaction primopseq() returns bool { | ||
return(5 == 9); | ||
} | ||
transaction primopseq() returns bool { | ||
return(5 == 9); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsGreater{ | ||
transaction primopsgreater() returns bool { | ||
return(12 > 19); | ||
} | ||
transaction primopsgreater() returns bool { | ||
return(12 > 19); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsGreaterEq{ | ||
transaction primopsgreatereq() returns bool { | ||
return(12 >= 12); | ||
} | ||
transaction primopsgreatereq() returns bool { | ||
return(12 >= 12); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsLess{ | ||
transaction primopsless() returns bool { | ||
return(9 < 10); | ||
} | ||
transaction primopsless() returns bool { | ||
return(9 < 10); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsLessEq{ | ||
transaction primopslesseq() returns bool { | ||
return(9 <= 19); | ||
} | ||
transaction primopslesseq() returns bool { | ||
return(9 <= 19); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsMod{ | ||
transaction primopsmod() returns int { | ||
return(13 % 8); | ||
} | ||
transaction primopsmod() returns int { | ||
return(13 % 8); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsMul{ | ||
transaction primopsmul() returns int { | ||
return(5*4); | ||
} | ||
transaction primopsmul() returns int { | ||
return(5*4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsNEq{ | ||
transaction primopsneq() returns bool { | ||
return(5 != 9); | ||
} | ||
transaction primopsneq() returns bool { | ||
return(5 != 9); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsNeg{ | ||
transaction primopsneg() returns int { | ||
return(-20); | ||
} | ||
transaction primopsneg() returns int { | ||
return(-20); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsNotFalse{ | ||
transaction primopsnotfalse() returns bool { | ||
return(! false); | ||
} | ||
transaction primopsnotfalse() returns bool { | ||
return(! false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsNotTrue{ | ||
transaction primopsnottrue() returns bool { | ||
return(! true); | ||
} | ||
transaction primopsnottrue() returns bool { | ||
return(! true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsOr{ | ||
transaction primopsor() returns bool { | ||
return(true || false); | ||
} | ||
transaction primopsor() returns bool { | ||
return(true || false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsSubNeg{ | ||
transaction primopssubneg() returns int { | ||
return(5-20); | ||
} | ||
transaction primopssubneg() returns int { | ||
return(5-20); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
main contract PrimOpsSubPos{ | ||
transaction primopssubpos() returns int { | ||
return(20-5); | ||
} | ||
transaction primopssubpos() returns int { | ||
return(20-5); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
main contract Return { | ||
transaction f() returns int{ | ||
return (4+4); | ||
} | ||
transaction g(){ | ||
int x = f(); | ||
return; | ||
} | ||
transaction f() returns int{ | ||
return (4+4); | ||
} | ||
transaction g(){ | ||
int x = f(); | ||
return; | ||
} | ||
|
||
transaction main() returns int{ | ||
return f(); | ||
} | ||
transaction main() returns int{ | ||
return f(); | ||
} | ||
} |
Oops, something went wrong.