1- import path from "node:path" ;
2- import createEsmUtils from "esm-utils" ;
31import { FULL_TEST } from "./constants.js" ;
42import * as failedTests from "./failed-format-tests.js" ;
53import { format } from "./run-prettier.js" ;
@@ -10,48 +8,12 @@ import * as testAstCompare from "./test-ast-compare.js";
108import * as testBom from "./test-bom.js" ;
119import * as testEndOfLine from "./test-end-of-line.js" ;
1210import * as testSecondFormat from "./test-second-format.js" ;
11+ import * as testBytecodeCompare from "./test-bytecode-compare.js" ;
1312import { shouldThrowOnFormat } from "./utilities.js" ;
1413import getPrettier from "./get-prettier.js" ;
1514import getCreateParser from "./get-create-parser.js" ;
1615import getVariantCoverage from "./get-variant-coverage.js" ;
1716import getPlugins from "./get-plugins.js" ;
18- import compileContract from "./utils/compile-contract.js" ;
19-
20- const { __dirname } = createEsmUtils ( import . meta) ;
21-
22- const testsWithAstChanges = new Map (
23- [
24- "Parentheses/AddNoParentheses.sol" ,
25- "Parentheses/SubNoParentheses.sol" ,
26- "Parentheses/MulNoParentheses.sol" ,
27- "Parentheses/DivNoParentheses.sol" ,
28- "Parentheses/ModNoParentheses.sol" ,
29- "Parentheses/ExpNoParentheses.sol" ,
30- "Parentheses/ShiftLNoParentheses.sol" ,
31- "Parentheses/ShiftRNoParentheses.sol" ,
32- "Parentheses/BitAndNoParentheses.sol" ,
33- "Parentheses/BitOrNoParentheses.sol" ,
34- "Parentheses/BitXorNoParentheses.sol" ,
35- "Parentheses/LogicNoParentheses.sol" ,
36- "HexLiteral/HexLiteral.sol" ,
37- "ModifierInvocations/ModifierInvocations.sol" ,
38- ] . map ( ( fixture ) => {
39- const [ file , compareBytecode = ( ) => true ] = Array . isArray ( fixture )
40- ? fixture
41- : [ fixture ] ;
42- return [ path . join ( __dirname , "../format/" , file ) , compareBytecode ] ;
43- } ) ,
44- ) ;
45-
46- const shouldCompareBytecode = ( filename , options ) => {
47- const testFunction = testsWithAstChanges . get ( filename ) ;
48-
49- if ( ! testFunction ) {
50- return false ;
51- }
52-
53- return testFunction ( options ) ;
54- } ;
5517
5618async function runTest ( {
5719 parsers,
@@ -134,12 +96,7 @@ async function runTest({
13496 await testEndOfLine . run ( code , formatResult , filename , formatOptions , "\r\n" ) ;
13597 await testEndOfLine . run ( code , formatResult , filename , formatOptions , "\r" ) ;
13698 await testBom . run ( code , formatResult , filename , formatOptions ) ;
137-
138- if ( shouldCompareBytecode ( filename , formatOptions ) ) {
139- const output = compileContract ( filename , formatResult . output ) ;
140- const expected = compileContract ( filename , formatResult . input ) ;
141- expect ( output ) . toEqual ( expected ) ;
142- }
99+ await testBytecodeCompare . run ( code , formatResult , filename , formatOptions ) ;
143100}
144101
145102export { runTest } ;
0 commit comments