@@ -16,14 +16,6 @@ describe('inferLanguage', function () {
1616 source : `pragma solidity 0.8.1;` ,
1717 version : '0.8.1'
1818 } ,
19- {
20- description : 'With nightly commit' ,
21- source : `pragma solidity 0.8.18-ci.2023.1.17+commit.e7b959af;` ,
22- version : '0.8.18' ,
23- // TODO: unskip this test when addresses this issue
24- // https://github.com/NomicFoundation/slang/issues/1346
25- skip : true
26- } ,
2719 {
2820 description : 'Caret range and pinned version' ,
2921 source : `pragma solidity ^0.8.0; pragma solidity 0.8.2;` ,
@@ -84,9 +76,7 @@ describe('inferLanguage', function () {
8476 description :
8577 'should use the latest version if the range is outside the supported versions' ,
8678 source : `pragma solidity ^10.0.0;` ,
87- version : latestSupportedVersion ,
88- // TODO: unskip this test when slack fixes the error with ranges outside the supported versions.
89- skip : true
79+ version : latestSupportedVersion
9080 }
9181 ] ;
9282
@@ -120,9 +110,44 @@ describe('inferLanguage', function () {
120110 expect ( parser . languageVersion ) . toEqual ( '0.8.0' ) ;
121111 } ) ;
122112
123- test ( 'should throw an error if there are incompatible ranges' , function ( ) {
113+ test ( 'should throw if compiler option does not match the syntax' , function ( ) {
114+ expect ( ( ) =>
115+ createParser ( `contract Foo {byte bar;}` , { compiler : '0.8.0' } )
116+ ) . toThrow (
117+ 'Based on the compiler option provided, we inferred your code to be using Solidity version'
118+ ) ;
119+ } ) ;
120+
121+ test ( 'should throw if pragma is outside the supported version and the syntax does not match with the latest supported version' , function ( ) {
122+ expect ( ( ) =>
123+ createParser ( `pragma solidity 10.0.0;contract Foo {byte bar;}` , options )
124+ ) . toThrow (
125+ "We couldn't infer a Solidity version based on the pragma statements"
126+ ) ;
127+ } ) ;
128+
129+ test ( 'should throw if there is no pragma and the syntax does not match with the latest supported version' , function ( ) {
130+ expect ( ( ) => createParser ( `contract Foo {byte bar;}` , options ) ) . toThrow (
131+ "We couldn't infer a Solidity version based on the pragma statements"
132+ ) ;
133+ } ) ;
134+
135+ test ( 'should throw an error if there are incompatible ranges and the syntax does not match with the latest supported version' , function ( ) {
136+ expect ( ( ) =>
137+ createParser (
138+ `pragma solidity ^0.8.0; pragma solidity 0.7.6;contract Foo {byte bar;}` ,
139+ options
140+ )
141+ ) . toThrow (
142+ "We couldn't infer a Solidity version based on the pragma statements"
143+ ) ;
144+ } ) ;
145+
146+ test ( 'should throw an error if the pragma statement is and the syntax do not match' , function ( ) {
124147 expect ( ( ) =>
125- createParser ( `pragma solidity ^0.8.0; pragma solidity 0.7.6;` , options )
126- ) . toThrow ( ) ;
148+ createParser ( `pragma solidity ^0.8.0;contract Foo {byte bar;}` , options )
149+ ) . toThrow (
150+ 'Based on the pragma statements, we inferred your code to be using Solidity version'
151+ ) ;
127152 } ) ;
128153} ) ;
0 commit comments