@@ -493,9 +493,49 @@ function runTests (solc, versionText) {
493
493
var L = getBytecodeStandard ( output , 'lib.sol' , 'L' ) ;
494
494
st . ok ( typeof L === 'string' ) ;
495
495
st . ok ( L . length > 0 ) ;
496
+ st . end ( ) ;
497
+ } ) ;
498
+
499
+ t . test ( 'compiling standard JSON (with imports + new callback API)' , function ( st ) {
500
+ // <0.2.1 doesn't have this
501
+ if ( ! solc . features . importCallback ) {
502
+ st . skip ( 'Not supported by solc' ) ;
503
+ st . end ( ) ;
504
+ return ;
505
+ }
506
+
507
+ var input = {
508
+ 'language' : 'Solidity' ,
509
+ 'settings' : {
510
+ 'outputSelection' : {
511
+ '*' : {
512
+ '*' : [ 'evm.bytecode' ]
513
+ }
514
+ }
515
+ } ,
516
+ 'sources' : {
517
+ 'cont.sol' : {
518
+ 'content' : 'import "lib.sol"; contract x { function g() public { L.f(); } }'
519
+ }
520
+ }
521
+ } ;
522
+
523
+ function findImports ( path ) {
524
+ if ( path === 'lib.sol' ) {
525
+ return { contents : 'library L { function f() public returns (uint) { return 7; } }' } ;
526
+ } else {
527
+ return { error : 'File not found' } ;
528
+ }
529
+ }
496
530
497
- var outputNewApi = JSON . parse ( solc . compile ( JSON . stringify ( input ) , { import : findImports } ) ) ;
498
- st . deepEqual ( output , outputNewApi ) ;
531
+ var output = JSON . parse ( solc . compile ( JSON . stringify ( input ) , { import : findImports } ) ) ;
532
+ st . ok ( expectNoError ( output ) ) ;
533
+ var x = getBytecodeStandard ( output , 'cont.sol' , 'x' ) ;
534
+ st . ok ( typeof x === 'string' ) ;
535
+ st . ok ( x . length > 0 ) ;
536
+ var L = getBytecodeStandard ( output , 'lib.sol' , 'L' ) ;
537
+ st . ok ( typeof L === 'string' ) ;
538
+ st . ok ( L . length > 0 ) ;
499
539
st . end ( ) ;
500
540
} ) ;
501
541
0 commit comments