1
1
import test from 'ava' ;
2
2
3
- import type { BaseFunction , BaseImplementedTrait } from './contract' ;
3
+ import type { BaseFunction , BaseTraitImplBlock } from './contract' ;
4
4
import { ContractBuilder } from './contract' ;
5
5
import { printContract } from './print' ;
6
6
@@ -23,39 +23,41 @@ test('contract with constructor code with semicolon', t => {
23
23
24
24
test ( 'contract with function code before' , t => {
25
25
const Foo = new ContractBuilder ( 'Foo' ) ;
26
- const trait : BaseImplementedTrait = {
27
- name : 'External' ,
28
- for : 'ExternalTrait' ,
26
+ const trait : BaseTraitImplBlock = {
27
+ traitName : 'External' ,
28
+ structName : 'ExternalTrait' ,
29
29
tags : [ 'othertag' , 'contractimpl' ] ,
30
30
} ;
31
- Foo . addImplementedTrait ( trait ) ;
31
+ Foo . addTraitImplBlock ( trait ) ;
32
32
const fn : BaseFunction = {
33
+ pub : false ,
33
34
name : 'someFunction' ,
34
35
args : [ ] ,
35
36
code : [ 'someFunction()' ] ,
36
37
} ;
37
- Foo . addFunction ( trait , fn ) ;
38
- Foo . addFunctionTag ( trait , fn , 'functiontag' ) ;
39
- Foo . addFunctionCodeBefore ( trait , fn , [ 'before()' ] ) ;
38
+ Foo . addTraitFunction ( trait , fn ) ;
39
+ Foo . addFunctionTag ( fn , 'functiontag' , trait ) ;
40
+ Foo . addFunctionCodeBefore ( fn , [ 'before()' ] , trait ) ;
40
41
t . snapshot ( printContract ( Foo ) ) ;
41
42
} ) ;
42
43
43
44
test ( 'contract with function code before with semicolons' , t => {
44
45
const Foo = new ContractBuilder ( 'Foo' ) ;
45
- const trait : BaseImplementedTrait = {
46
- name : 'External' ,
47
- for : 'ExternalTrait' ,
46
+ const trait : BaseTraitImplBlock = {
47
+ traitName : 'External' ,
48
+ structName : 'ExternalTrait' ,
48
49
tags : [ 'othertag' , 'contractimpl' ] ,
49
50
} ;
50
- Foo . addImplementedTrait ( trait ) ;
51
+ Foo . addTraitImplBlock ( trait ) ;
51
52
const fn : BaseFunction = {
53
+ pub : false ,
52
54
name : 'someFunction' ,
53
55
args : [ ] ,
54
56
code : [ 'someFunction();' ] ,
55
57
} ;
56
- Foo . addFunction ( trait , fn ) ;
57
- Foo . addFunctionTag ( trait , fn , 'functiontag' ) ;
58
- Foo . addFunctionCodeBefore ( trait , fn , [ 'before();' ] ) ;
58
+ Foo . addTraitFunction ( trait , fn ) ;
59
+ Foo . addFunctionTag ( fn , 'functiontag' , trait ) ;
60
+ Foo . addFunctionCodeBefore ( fn , [ 'before();' ] , trait ) ;
59
61
t . snapshot ( printContract ( Foo ) ) ;
60
62
} ) ;
61
63
0 commit comments