File tree 2 files changed +48
-0
lines changed
test/externalTests/solc-js
2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change
1
+ const tape = require ( 'tape' ) ;
2
+ const fs = require ( 'fs' ) ;
3
+ const solc = require ( '../index.js' ) ;
4
+
5
+ tape ( 'ASM Json output consistency' , function ( t ) {
6
+ t . test ( 'Nested structure' , function ( st ) {
7
+ const testdir = 'test/' ;
8
+ const output = JSON . parse ( solc . compile ( JSON . stringify ( {
9
+ language : 'Solidity' ,
10
+ settings : {
11
+ viaIR : true ,
12
+ outputSelection : {
13
+ '*' : {
14
+ '*' : [ 'evm.legacyAssembly' ]
15
+ }
16
+ }
17
+ } ,
18
+ sources : {
19
+ C : {
20
+ content : fs . readFileSync ( testdir + 'code_access_runtime.sol' , 'utf8' )
21
+ }
22
+ }
23
+ } ) ) ) ;
24
+ st . ok ( output ) ;
25
+
26
+ function containsTarget ( obj , target ) {
27
+ if ( Array . isArray ( obj ) )
28
+ return obj . some ( item => containsTarget ( item , target ) ) ;
29
+ else if ( typeof obj === 'object' && obj !== null ) {
30
+ if ( obj . name === target . name && obj . value === target . value )
31
+ return true ;
32
+ return Object . values ( obj ) . some ( value => containsTarget ( value , target ) ) ;
33
+ }
34
+ return false ;
35
+ }
36
+
37
+ // regression test that there is indeed a negative subassembly index in there
38
+ // and it is based on a 64 bit uint
39
+ const targetObject = {
40
+ "name" : "PUSH #[$]" ,
41
+ "value" : "000000000000000000000000000000000000000000000000ffffffffffffffff"
42
+ } ;
43
+ st . equal ( containsTarget ( output , targetObject ) , true )
44
+ } ) ;
45
+ } ) ;
Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ function solcjs_test
48
48
printLog " Copying contracts..."
49
49
cp -Rf " $SOLCJS_INPUT_DIR /DAO" test/
50
50
51
+ printLog " Copying test with non-zero subassembly access"
52
+ cp -f " $TEST_DIR " /test/libsolidity/semanticTests/various/code_access_runtime.sol test/
53
+
51
54
printLog " Copying SMTChecker tests..."
52
55
# We do not copy all tests because that takes too long.
53
56
cp -Rf " $TEST_DIR " /test/libsolidity/smtCheckerTests/external_calls test/smtCheckerTests/
You can’t perform that action at this time.
0 commit comments