@@ -426,45 +426,56 @@ import "SomeFile.sol" as SomeOtherFile;
426426import "AnotherFile.sol" as SomeSymbol;
427427import { symbol1 as alias , symbol2 } from "File.sol";
428428
429+
429430interface i {
430431 function f();
431432}
432433
434+
433435contract c {
434436 function c() {
435437 val1 = 1 wei ; // 1
436438 val2 = 1 szabo ; // 1 * 10 ** 12
437439 val3 = 1 finney ; // 1 * 10 ** 15
438440 val4 = 1 ether ; // 1 * 10 ** 18
439441 }
442+
440443 uint256 val1 ;
441444 uint256 val2 ;
442445 uint256 val3 ;
443446 uint256 val4 ;
444447}
445448
449+
446450contract test {
447451 enum ActionChoices {GoLeft , GoRight , GoStraight , SitStill }
448452
449453 function test() {
450454 choices = ActionChoices .GoStraight ;
451455 }
456+
452457 function getChoice() returns (uint256 d ) {
453458 d = uint256 (choices );
454459 }
460+
455461 ActionChoices choices ;
456462}
457463
464+
458465contract Base {
459466 function Base(uint256 i ) {
460467 m_i = i ;
461468 }
469+
462470 uint256 public m_i ;
463471}
472+
473+
464474contract Derived is Base(0) {
465475 function Derived(uint256 i ) Base(i ) {}
466476}
467477
478+
468479contract C {
469480 uint248 x ; // 31 bytes: slot 0, offset 0
470481 uint16 y ; // 2 bytes: slot 1, offset 0 (does not fit in slot 0)
@@ -480,6 +491,7 @@ contract C {
480491 uint8 gamma ; // 1 byte, slot 7 (start new slot after array)
481492}
482493
494+
483495contract test {
484496 function f(uint256 x , uint256 y ) returns (uint256 z ) {
485497 var c = x + 3 ;
@@ -488,36 +500,44 @@ contract test {
488500 }
489501}
490502
503+
491504contract test {
492505 function f(uint256 x , uint256 y ) returns (uint256 z ) {
493506 return 10 ;
494507 }
495508}
496509
510+
497511contract c {
498512 function () returns (uint256 ) {
499513 return g (8 );
500514 }
515+
501516 function g(uint256 pos ) internal returns (uint256 ) {
502517 setData (pos , 8 );
503518 return getData (pos );
504519 }
520+
505521 function setData(uint256 pos , uint256 value ) internal {
506522 data [pos ] = value ;
507523 }
524+
508525 function getData(uint256 pos ) internal {
509526 return data [pos ];
510527 }
528+
511529 mapping (uint256 => uint256 ) data ;
512530}
513531
532+
514533contract Sharer {
515534 function sendHalf(address addr ) returns (uint256 balance ) {
516535 if (! addr .send (msg .value / 2 )) throw ; // also reverts the transfer to Sharer
517536 return address (this ).balance ;
518537 }
519538}
520539
540+
521541/// @dev Models a modifiable and iterable set of uint values.
522542library IntegerSet {
523543 struct data {
@@ -528,6 +548,7 @@ library IntegerSet {
528548 // / Number of stored items.
529549 uint256 size;
530550 }
551+
531552 function insert(data storage self , uint256 value )
532553 returns (bool alreadyPresent )
533554 {
@@ -542,22 +563,27 @@ library IntegerSet {
542563 return false ;
543564 }
544565 }
566+
545567 function remove(data storage self , uint256 value ) returns (bool success ) {
546568 uint256 index = self .index [value ];
547569 if (index == 0 ) return false ;
548570 delete self .index [value ];
549571 delete self .items [index ];
550572 self .size -- ;
551573 }
574+
552575 function contains(data storage self , uint256 value ) returns (bool ) {
553576 return self .index [value ] > 0 ;
554577 }
578+
555579 function iterate_start(data storage self ) returns (uint256 index ) {
556580 return iterate_advance (self , 0 );
557581 }
582+
558583 function iterate_valid(data storage self , uint256 index ) returns (bool ) {
559584 return index < self .items .length ;
560585 }
586+
561587 function iterate_advance(data storage self , uint256 index )
562588 returns (uint256 r_index )
563589 {
@@ -567,24 +593,28 @@ library IntegerSet {
567593 ) index ++ ;
568594 return index ;
569595 }
596+
570597 function iterate_get(data storage self , uint256 index )
571598 returns (uint256 value )
572599 {
573600 return self .items [index ];
574601 }
575602}
576603
604+
577605/// How to use it:
578606contract User {
579607 // / Just a struct holding our data.
580608 IntegerSet .data data ;
609+
581610 // / Insert something
582611 function insert(uint256 v ) returns (uint256 size ) {
583612 // / Sends \`data\` via reference, so IntegerSet can modify it.
584613 IntegerSet .insert (data , v );
585614 // / We can access members of the struct - but we should take care not to mess with them.
586615 return data .size ;
587616 }
617+
588618 // / Computes the sum of all stored data.
589619 function sum() returns (uint256 s ) {
590620 for (
@@ -595,6 +625,7 @@ contract User {
595625 }
596626}
597627
628+
598629// This broke it at one point (namely the modifiers).
599630contract DualIndex {
600631 mapping (uint256 => mapping (uint256 => uint256 )) data ;
@@ -622,20 +653,26 @@ contract DualIndex {
622653 }
623654}
624655
656+
625657contract A { }
626658
659+
627660contract B { }
628661
662+
629663contract C is A, B { }
630664
665+
631666contract TestPrivate {
632667 uint256 private value ;
633668}
634669
670+
635671contract TestInternal {
636672 uint256 internal value ;
637673}
638674
675+
639676contract FromSolparse is A, B, TestPrivate, TestInternal {
640677 function () {
641678 uint256 a = 6 ** 9 ;
@@ -644,6 +681,7 @@ contract FromSolparse is A, B, TestPrivate, TestInternal {
644681 }
645682}
646683
684+
647685contract CommentedOutFunction {
648686 // FYI: This empty function, as well as the commented
649687 // out function below (bad code) is important to this test.
@@ -652,24 +690,27 @@ contract CommentedOutFunction {
652690 // function something()
653691 // uint x = 10;
654692 // }
655-
656693}
657694
695+
658696library VarHasBrackets {
659697 string constant specialRight = " }" ;
660698 // string storage specialLeft = "{";
661699}
662700
701+
663702library UsingExampleLibrary {
664703 function sum(uint256 [] storage self ) returns (uint256 s ) {
665704 for (uint256 i = 0 ; i < self .length ; i ++ ) s += self [i ];
666705 }
667706}
668707
708+
669709contract UsingExampleContract {
670710 using UsingExampleLibrary for uint256 [];
671711}
672712
713+
673714contract NewStuff {
674715 uint256 [] b ;
675716
@@ -679,11 +720,13 @@ contract NewStuff {
679720 }
680721}
681722
723+
682724// modifier with expression
683725contract MyContract {
684726 function fun() mymodifier(foo .bar ()) {}
685727}
686728
729+
687730library GetCode {
688731 function at(address _addr ) returns (bytes o_code ) {
689732 assembly {
@@ -705,6 +748,7 @@ library GetCode {
705748 }
706749}
707750
751+
708752contract assemblyLocalBinding {
709753 function test() {
710754 assembly {
@@ -716,6 +760,7 @@ contract assemblyLocalBinding {
716760 }
717761}
718762
763+
719764contract assemblyReturn {
720765 uint256 a = 10 ;
721766
@@ -729,10 +774,12 @@ contract assemblyReturn {
729774 }
730775}
731776
777+
732778contract usesConst {
733779 uint256 const = 0 ;
734780}
735781
782+
736783contract memoryArrays {
737784 uint256 seven = 7 ;
738785
@@ -746,6 +793,7 @@ contract memoryArrays {
746793 }
747794}
748795
796+
749797contract DeclarativeExpressions {
750798 uint256 a ;
751799 uint256 b = 7 ;
@@ -767,6 +815,7 @@ contract DeclarativeExpressions {
767815 }
768816}
769817
818+
770819contract VariableDeclarationTuple {
771820 function getMyTuple() returns (bool , bool ) {
772821 return (true , false );
@@ -783,11 +832,13 @@ contract VariableDeclarationTuple {
783832 }
784833}
785834
835+
786836contract TypeIndexSpacing {
787837 uint256 [7 ] x ;
788838 uint256 [] y ;
789839}
790840
841+
791842contract Ballot {
792843 struct Voter {
793844 uint256 weight;
@@ -803,6 +854,7 @@ contract Ballot {
803854 owner(myPrice )
804855 returns (uint256 [], address myAdd , string [] names )
805856 {}
857+
806858 function foobar()
807859 payable
808860 owner(myPrice )
@@ -815,6 +867,7 @@ contract Ballot {
815867 Voter airbnb = Voter ({weight: 2 , voted: true });
816868}
817869
870+
818871contract multilineReturn {
819872 function a() returns (uint256 x ) {
820873 return 5 ;
0 commit comments