1+ const assert = require ( 'assert' ) ;
12const tape = require ( 'tape' ) ;
23const semver = require ( 'semver' ) ;
34const solc = require ( '../index.js' ) ;
@@ -9,6 +10,16 @@ var noRemoteVersions = (process.argv.indexOf('--no-remote-versions') >= 0);
910function runTests ( solc , versionText ) {
1011 console . log ( `Running tests with ${ versionText } ${ solc . version ( ) } ` ) ;
1112
13+ function resplitFileNameOnFirstColon ( fileName , contractName ) {
14+ assert ( ! contractName . includes ( ':' ) ) ;
15+
16+ let contractNameComponents = fileName . split ( ':' ) ;
17+ const truncatedFileName = contractNameComponents . shift ( ) ;
18+ contractNameComponents . push ( contractName ) ;
19+
20+ return [ truncatedFileName , contractNameComponents . join ( ':' ) ] ;
21+ }
22+
1223 function getBytecode ( output , fileName , contractName ) {
1324 try {
1425 var outputContract ;
@@ -29,6 +40,9 @@ function runTests (solc, versionText) {
2940 if ( semver . lt ( solc . semver ( ) , '0.4.9' ) ) {
3041 outputFile = output . contracts [ '' ] ;
3142 } else {
43+ if ( semver . gt ( solc . semver ( ) , '0.4.10' ) && semver . lt ( solc . semver ( ) , '0.4.20' ) ) {
44+ [ fileName , contractName ] = resplitFileNameOnFirstColon ( fileName , contractName ) ;
45+ }
3246 outputFile = output . contracts [ fileName ] ;
3347 }
3448 return outputFile [ contractName ] [ 'evm' ] [ 'bytecode' ] [ 'object' ] ;
@@ -43,6 +57,9 @@ function runTests (solc, versionText) {
4357 if ( semver . lt ( solc . semver ( ) , '0.4.9' ) ) {
4458 outputFile = output . contracts [ '' ] ;
4559 } else {
60+ if ( semver . gt ( solc . semver ( ) , '0.4.10' ) && semver . gt ( solc . semver ( ) , '0.4.20' ) ) {
61+ [ fileName , contractName ] = resplitFileNameOnFirstColon ( fileName , contractName ) ;
62+ }
4663 outputFile = output . contracts [ fileName ] ;
4764 }
4865 return outputFile [ contractName ] [ 'evm' ] [ 'gasEstimates' ] ;
@@ -782,6 +799,31 @@ function runTests (solc, versionText) {
782799 st . ok ( C . length > 0 ) ;
783800 st . end ( ) ;
784801 } ) ;
802+
803+ t . test ( 'compiling standard JSON (file names containing multiple semicolons)' , function ( st ) {
804+ var input = {
805+ 'language' : 'Solidity' ,
806+ 'settings' : {
807+ 'outputSelection' : {
808+ '*' : {
809+ '*' : [ 'evm.bytecode' ]
810+ }
811+ }
812+ } ,
813+ 'sources' : {
814+ 'a:b:c:d:e:f:G.sol' : {
815+ 'content' : 'contract G {}'
816+ }
817+ }
818+ } ;
819+
820+ var output = JSON . parse ( solc . compile ( JSON . stringify ( input ) ) ) ;
821+ st . ok ( expectNoError ( output ) ) ;
822+ var G = getBytecodeStandard ( output , 'a:b:c:d:e:f:G.sol' , 'G' ) ;
823+ st . ok ( typeof G === 'string' ) ;
824+ st . ok ( G . length > 0 ) ;
825+ st . end ( ) ;
826+ } ) ;
785827 } ) ;
786828 } ) ;
787829
@@ -835,9 +877,12 @@ if (!noRemoteVersions) {
835877 'v0.2.1+commit.91a6b35' ,
836878 'v0.3.6+commit.3fc68da' ,
837879 'v0.4.0+commit.acd334c9' ,
880+ 'v0.4.9+commit.364da425' ,
838881 'v0.4.10+commit.f0d539ae' ,
839882 'v0.4.11+commit.68ef5810' ,
840883 'v0.4.12+commit.194ff033' ,
884+ 'v0.4.19+commit.c4cbbb05' ,
885+ 'v0.4.20+commit.3155dd80' ,
841886 'v0.4.26+commit.4563c3fc'
842887 ] ;
843888 for ( var version in versions ) {
0 commit comments