@@ -55,9 +55,12 @@ function runTests (solc, versionText) {
55
55
error = output . errors [ error ] ;
56
56
if ( error . type === errorType ) {
57
57
if ( message ) {
58
- return error . message . match ( message ) !== null ;
58
+ if ( error . message . match ( message ) !== null ) {
59
+ return true ;
60
+ }
61
+ } else {
62
+ return true ;
59
63
}
60
- return true ;
61
64
}
62
65
}
63
66
}
@@ -421,7 +424,40 @@ function runTests (solc, versionText) {
421
424
st . end ( ) ;
422
425
} ) ;
423
426
424
- t . test ( 'compiling standard JSON' , function ( st ) {
427
+ t . test ( 'compiling standard JSON (single file)' , function ( st ) {
428
+ var input = {
429
+ 'language' : 'Solidity' ,
430
+ 'settings' : {
431
+ 'outputSelection' : {
432
+ '*' : {
433
+ '*' : [ 'evm.bytecode' , 'evm.gasEstimates' ]
434
+ }
435
+ }
436
+ } ,
437
+ 'sources' : {
438
+ 'c.sol' : {
439
+ 'content' : 'contract C { function g() public { } function h() internal {} }'
440
+ }
441
+ }
442
+ } ;
443
+
444
+ var output = JSON . parse ( solc . compile ( JSON . stringify ( input ) ) ) ;
445
+ st . ok ( expectNoError ( output ) ) ;
446
+ var C = getBytecodeStandard ( output , 'c.sol' , 'C' ) ;
447
+ st . ok ( typeof C === 'string' ) ;
448
+ st . ok ( C . length > 0 ) ;
449
+ var CGas = getGasEstimate ( output , 'c.sol' , 'C' ) ;
450
+ st . ok ( typeof CGas === 'object' ) ;
451
+ st . ok ( typeof CGas [ 'creation' ] === 'object' ) ;
452
+ st . ok ( typeof CGas [ 'creation' ] [ 'codeDepositCost' ] === 'string' ) ;
453
+ st . ok ( typeof CGas [ 'external' ] === 'object' ) ;
454
+ st . ok ( typeof CGas [ 'external' ] [ 'g()' ] === 'string' ) ;
455
+ st . ok ( typeof CGas [ 'internal' ] === 'object' ) ;
456
+ st . ok ( typeof CGas [ 'internal' ] [ 'h()' ] === 'string' ) ;
457
+ st . end ( ) ;
458
+ } ) ;
459
+
460
+ t . test ( 'compiling standard JSON (multiple files)' , function ( st ) {
425
461
// <0.1.6 doesn't have this
426
462
if ( ! solc . features . multipleInputs ) {
427
463
st . skip ( 'Not supported by solc' ) ;
@@ -468,6 +504,40 @@ function runTests (solc, versionText) {
468
504
st . end ( ) ;
469
505
} ) ;
470
506
507
+ t . test ( 'compiling standard JSON (abstract contract)' , function ( st ) {
508
+ // <0.1.6 doesn't have this
509
+ if ( ! solc . features . multipleInputs ) {
510
+ st . skip ( 'Not supported by solc' ) ;
511
+ st . end ( ) ;
512
+ return ;
513
+ }
514
+
515
+ var isVersion6 = semver . gt ( solc . semver ( ) , '0.5.99' ) ;
516
+
517
+ var input = {
518
+ 'language' : 'Solidity' ,
519
+ 'settings' : {
520
+ 'outputSelection' : {
521
+ '*' : {
522
+ '*' : [ 'evm.bytecode' , 'evm.gasEstimates' ]
523
+ }
524
+ }
525
+ } ,
526
+ 'sources' : {
527
+ 'c.sol' : {
528
+ 'content' : ( isVersion6 ? 'abstract ' : '' ) + 'contract C { function f() public; }'
529
+ }
530
+ }
531
+ } ;
532
+
533
+ var output = JSON . parse ( solc . compile ( JSON . stringify ( input ) ) ) ;
534
+ st . ok ( expectNoError ( output ) ) ;
535
+ var C = getBytecodeStandard ( output , 'c.sol' , 'C' ) ;
536
+ st . ok ( typeof C === 'string' ) ;
537
+ st . ok ( C . length === 0 ) ;
538
+ st . end ( ) ;
539
+ } ) ;
540
+
471
541
t . test ( 'compiling standard JSON (with imports)' , function ( st ) {
472
542
// <0.2.1 doesn't have this
473
543
if ( ! solc . features . importCallback ) {
@@ -606,6 +676,35 @@ function runTests (solc, versionText) {
606
676
st . end ( ) ;
607
677
} ) ;
608
678
679
+ t . test ( 'compiling standard JSON (with warning >=0.4.0)' , function ( st ) {
680
+ // In 0.4.0 "pragma solidity" was added. Not including it is a warning.
681
+ if ( semver . lt ( solc . semver ( ) , '0.4.0' ) ) {
682
+ st . skip ( 'Not supported by solc' ) ;
683
+ st . end ( ) ;
684
+ return ;
685
+ }
686
+
687
+ var input = {
688
+ 'language' : 'Solidity' ,
689
+ 'settings' : {
690
+ 'outputSelection' : {
691
+ '*' : {
692
+ '*' : [ 'evm.bytecode' ]
693
+ }
694
+ }
695
+ } ,
696
+ 'sources' : {
697
+ 'c.sol' : {
698
+ 'content' : 'contract C { function f() public { } }'
699
+ }
700
+ }
701
+ } ;
702
+
703
+ var output = JSON . parse ( solc . compile ( JSON . stringify ( input ) ) ) ;
704
+ st . ok ( expectError ( output , 'Warning' , 'Source file does not specify required compiler version!' ) ) ;
705
+ st . end ( ) ;
706
+ } ) ;
707
+
609
708
t . test ( 'compiling standard JSON (using libraries) (using lowlevel API)' , function ( st ) {
610
709
// 0.4.0 has a bug with libraries
611
710
if ( semver . eq ( solc . semver ( ) , '0.4.0' ) ) {
0 commit comments