@@ -1111,44 +1111,42 @@ func TestInterpretInterfaceFunctionConditionsInheritance(t *testing.T) {
1111
1111
1112
1112
t .Parallel ()
1113
1113
1114
- testWithConditionsDeduplication := func (t * testing.T , conditionsDeduplicationEnabled bool ) []string {
1115
-
1116
- var logs []string
1117
-
1118
- logFunction := stdlib .NewStandardLibraryStaticFunction (
1119
- "log" ,
1120
- & sema.FunctionType {
1121
- Parameters : []sema.Parameter {
1122
- {
1123
- Label : sema .ArgumentLabelNotRequired ,
1124
- Identifier : "value" ,
1125
- TypeAnnotation : sema .NewTypeAnnotation (sema .AnyStructType ),
1126
- },
1114
+ var logs []string
1115
+
1116
+ logFunction := stdlib .NewStandardLibraryStaticFunction (
1117
+ "log" ,
1118
+ & sema.FunctionType {
1119
+ Parameters : []sema.Parameter {
1120
+ {
1121
+ Label : sema .ArgumentLabelNotRequired ,
1122
+ Identifier : "value" ,
1123
+ TypeAnnotation : sema .NewTypeAnnotation (sema .AnyStructType ),
1127
1124
},
1128
- ReturnTypeAnnotation : sema .NewTypeAnnotation (
1129
- sema .VoidType ,
1130
- ),
1131
- Purity : sema .FunctionPurityView ,
1132
- },
1133
- `` ,
1134
- func (invocation interpreter.Invocation ) interpreter.Value {
1135
- message := invocation .Arguments [0 ].MeteredString (
1136
- invocation .Interpreter ,
1137
- interpreter.SeenReferences {},
1138
- invocation .LocationRange ,
1139
- )
1140
- logs = append (logs , message )
1141
- return interpreter .Void
1142
1125
},
1143
- )
1126
+ ReturnTypeAnnotation : sema .NewTypeAnnotation (
1127
+ sema .VoidType ,
1128
+ ),
1129
+ Purity : sema .FunctionPurityView ,
1130
+ },
1131
+ `` ,
1132
+ func (invocation interpreter.Invocation ) interpreter.Value {
1133
+ message := invocation .Arguments [0 ].MeteredString (
1134
+ invocation .Interpreter ,
1135
+ interpreter.SeenReferences {},
1136
+ invocation .LocationRange ,
1137
+ )
1138
+ logs = append (logs , message )
1139
+ return interpreter .Void
1140
+ },
1141
+ )
1144
1142
1145
- baseValueActivation := sema .NewVariableActivation (sema .BaseValueActivation )
1146
- baseValueActivation .DeclareValue (logFunction )
1143
+ baseValueActivation := sema .NewVariableActivation (sema .BaseValueActivation )
1144
+ baseValueActivation .DeclareValue (logFunction )
1147
1145
1148
- baseActivation := activations .NewActivation (nil , interpreter .BaseActivation )
1149
- interpreter .Declare (baseActivation , logFunction )
1146
+ baseActivation := activations .NewActivation (nil , interpreter .BaseActivation )
1147
+ interpreter .Declare (baseActivation , logFunction )
1150
1148
1151
- code := `
1149
+ code := `
1152
1150
struct interface Foo {
1153
1151
fun test() {
1154
1152
pre {
@@ -1174,60 +1172,36 @@ func TestInterpretInterfaceFunctionConditionsInheritance(t *testing.T) {
1174
1172
}
1175
1173
`
1176
1174
1177
- inter , err := parseCheckAndInterpretWithOptions (
1178
- t ,
1179
- code ,
1180
- ParseCheckAndInterpretOptions {
1181
- Config : & interpreter.Config {
1182
- BaseActivationHandler : func (_ common.Location ) * interpreter.VariableActivation {
1183
- return baseActivation
1184
- },
1185
- FunctionConditionsDeduplicationEnabled : conditionsDeduplicationEnabled ,
1175
+ inter , err := parseCheckAndInterpretWithOptions (
1176
+ t ,
1177
+ code ,
1178
+ ParseCheckAndInterpretOptions {
1179
+ Config : & interpreter.Config {
1180
+ BaseActivationHandler : func (_ common.Location ) * interpreter.VariableActivation {
1181
+ return baseActivation
1186
1182
},
1187
- CheckerConfig : & sema. Config {
1188
- BaseValueActivationHandler : func ( _ common. Location ) * sema.VariableActivation {
1189
- return baseValueActivation
1190
- },
1183
+ },
1184
+ CheckerConfig : & sema.Config {
1185
+ BaseValueActivationHandler : func ( _ common. Location ) * sema. VariableActivation {
1186
+ return baseValueActivation
1191
1187
},
1192
- HandleCheckerError : nil ,
1193
1188
},
1194
- )
1195
- require .NoError (t , err )
1189
+ HandleCheckerError : nil ,
1190
+ },
1191
+ )
1192
+ require .NoError (t , err )
1196
1193
1197
- _ , err = inter .Invoke ("main" )
1198
- require .NoError (t , err )
1199
- return logs
1200
- }
1194
+ _ , err = inter .Invoke ("main" )
1195
+ require .NoError (t , err )
1201
1196
1202
- t .Run ("enabled" , func (t * testing.T ) {
1203
- t .Parallel ()
1204
-
1205
- logs := testWithConditionsDeduplication (t , true )
1206
- require .Equal (
1207
- t ,
1208
- []string {
1209
- `"invoked Foo.test() pre-condition"` ,
1210
- `"invoked Foo.test()"` ,
1211
- `"invoked Foo.test() post-condition"` ,
1212
- }, logs ,
1213
- )
1214
- })
1215
-
1216
- t .Run ("disabled" , func (t * testing.T ) {
1217
- t .Parallel ()
1218
-
1219
- logs := testWithConditionsDeduplication (t , false )
1220
- require .Equal (
1221
- t ,
1222
- []string {
1223
- `"invoked Foo.test() pre-condition"` ,
1224
- `"invoked Foo.test() pre-condition"` ,
1225
- `"invoked Foo.test()"` ,
1226
- `"invoked Foo.test() post-condition"` ,
1227
- `"invoked Foo.test() post-condition"` ,
1228
- }, logs ,
1229
- )
1230
- })
1197
+ require .Equal (
1198
+ t ,
1199
+ []string {
1200
+ `"invoked Foo.test() pre-condition"` ,
1201
+ `"invoked Foo.test()"` ,
1202
+ `"invoked Foo.test() post-condition"` ,
1203
+ }, logs ,
1204
+ )
1231
1205
})
1232
1206
}
1233
1207
0 commit comments