@@ -11,6 +11,7 @@ import {
11
11
getFileSystem ,
12
12
Encoded ,
13
13
} from '../../src' ;
14
+ import { indent } from '../utils' ;
14
15
15
16
function testCompiler ( compiler : CompilerBase ) : void {
16
17
const inclSourceCodePath = './test/integration/contracts/Includes.aes' ;
@@ -94,36 +95,38 @@ function testCompiler(compiler: CompilerBase): void {
94
95
95
96
it ( 'throws clear exception if compile broken contract' , async ( ) => {
96
97
await expect (
97
- compiler . compileBySourceCode (
98
- 'contract Foo =\n' +
99
- ' entrypoint getArg(x : bar) = x\n' +
100
- ' entrypoint getArg(x : int) = baz\n' +
101
- ' entrypoint getArg1(x : int) = baz\n' ,
102
- ) ,
98
+ compiler . compileBySourceCode ( indent `
99
+ contract Foo =
100
+ entrypoint getArg(x : bar) = x
101
+ entrypoint getArg(x : int) = baz
102
+ entrypoint getArg1(x : int) = baz` ) ,
103
103
) . to . be . rejectedWith (
104
104
CompilerError ,
105
105
compiler instanceof CompilerCli
106
106
? / C o m m a n d f a i l e d : e s c r i p t .+ [ \\ / ] b i n [ \\ / ] a e s o p h i a _ c l i ( _ 8 ) ? ( - - c r e a t e _ j s o n _ a c i ) ? .+ \. a e s ( - - n o _ w a r n i n g a l l ) ? \n T y p e e r r o r ( i n ' .+ \. a e s ' ) ? a t l i n e 3 , c o l 3 : \n D u p l i c a t e d e f i n i t i o n s o f ` g e t A r g ` a t \n { 2 } - l i n e 2 , c o l u m n 3 \n { 2 } - l i n e 3 , c o l u m n 3 \n \n / m
107
- : 'compile error:\n' +
108
- 'type_error:3:3: Duplicate definitions of `getArg` at\n' +
109
- ' - line 2, column 3\n' +
110
- ' - line 3, column 3\n' +
111
- 'type_error:3:32: Unbound variable `baz`\n' +
112
- 'type_error:4:33: Unbound variable `baz`' ,
107
+ : indent `
108
+ compile error:
109
+ type_error:3:3: Duplicate definitions of \`getArg\` at
110
+ - line 2, column 3
111
+ - line 3, column 3
112
+ type_error:3:32: Unbound variable \`baz\`
113
+ type_error:4:33: Unbound variable \`baz\`` ,
113
114
) ;
114
115
} ) ;
115
116
116
117
it ( 'returns warnings' , async ( ) => {
117
118
const { warnings } = await compiler . compileBySourceCode (
118
- 'include "./lib/Library.aes"\n' +
119
- '\n' +
120
- 'main contract Foo =\n' +
121
- ' entrypoint getArg(x: int) =\n' +
122
- ' let t = 42\n' +
123
- ' x\n' ,
119
+ indent `
120
+ include "./lib/Library.aes"
121
+
122
+ main contract Foo =
123
+ entrypoint getArg(x: int) =
124
+ let t = 42
125
+ x` ,
124
126
{
125
- './lib/Library.aes' :
126
- '' + 'contract Library =\n' + ' entrypoint getArg() =\n' + ' 1 / 0\n' ,
127
+ './lib/Library.aes' : indent `
128
+ contract Library =
129
+ entrypoint getArg() = 1 / 0` ,
127
130
} ,
128
131
) ;
129
132
expect ( warnings ) . to . eql ( [
@@ -133,7 +136,7 @@ function testCompiler(compiler: CompilerBase): void {
133
136
} ,
134
137
{
135
138
message : 'Division by zero.' ,
136
- pos : { file : './lib/Library.aes' , col : 5 , line : 3 } ,
139
+ pos : { file : './lib/Library.aes' , col : 25 , line : 2 } ,
137
140
} ,
138
141
] ) ;
139
142
} ) ;
@@ -183,11 +186,15 @@ describe('CompilerHttp', () => {
183
186
it ( 'reads file system' , async ( ) => {
184
187
expect ( await getFileSystem ( './test/integration/contracts/Includes.aes' ) ) . to . be . eql ( {
185
188
'./lib/Library.aes' :
186
- 'include"lib/Sublibrary.aes"\n\n' +
187
- 'namespace Library =\n' +
188
- ' function sum(x: int, y: int): int = Sublibrary.sum(x, y)\n' ,
189
+ indent `
190
+ include"lib/Sublibrary.aes"
191
+
192
+ namespace Library =
193
+ function sum(x: int, y: int): int = Sublibrary.sum(x, y)` + '\n' ,
189
194
'lib/Sublibrary.aes' :
190
- 'namespace Sublibrary =\n' + ' function sum(x: int, y: int): int = x + y\n' ,
195
+ indent `
196
+ namespace Sublibrary =
197
+ function sum(x: int, y: int): int = x + y` + '\n' ,
191
198
} ) ;
192
199
} ) ;
193
200
} ) ;
0 commit comments