@@ -11,9 +11,10 @@ class JsonCodecCodeGenSpec extends GCodeGenSpec("Codec") {
11
11
val javaOption = " com.example.Option"
12
12
val scalaArray = " Vector"
13
13
val formatsForType : ast.Type => List [String ] = CodecCodeGen .formatsForType
14
+ val scalaVersion = " 2.13.15"
14
15
15
16
override def enumerationGenerateSimple = {
16
- val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil )
17
+ val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil , scalaVersion )
17
18
val enumeration = JsonParser .EnumTypeDefinition .parse(simpleEnumerationExample)
18
19
val code = gen generate enumeration
19
20
@@ -52,7 +53,7 @@ class JsonCodecCodeGenSpec extends GCodeGenSpec("Codec") {
52
53
}
53
54
54
55
override def interfaceGenerateSimple = {
55
- val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil )
56
+ val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil , scalaVersion )
56
57
val intf = JsonParser .InterfaceTypeDefinition .parseInterface(simpleInterfaceExample)
57
58
val code = gen generate intf
58
59
@@ -78,7 +79,7 @@ class JsonCodecCodeGenSpec extends GCodeGenSpec("Codec") {
78
79
}
79
80
80
81
override def interfaceGenerateOneChild = {
81
- val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil )
82
+ val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil , scalaVersion )
82
83
val intf = JsonParser .InterfaceTypeDefinition .parseInterface(oneChildInterfaceExample)
83
84
val code = gen generate intf
84
85
@@ -128,7 +129,7 @@ class JsonCodecCodeGenSpec extends GCodeGenSpec("Codec") {
128
129
}
129
130
130
131
override def interfaceGenerateNested = {
131
- val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil )
132
+ val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil , scalaVersion )
132
133
val intf = JsonParser .InterfaceTypeDefinition .parseInterface(nestedInterfaceExample)
133
134
val code = gen generate intf
134
135
@@ -149,7 +150,7 @@ class JsonCodecCodeGenSpec extends GCodeGenSpec("Codec") {
149
150
150
151
def interfaceGenerateMessages = {
151
152
val schema = JsonParser .Document .parse(generateArgDocExample)
152
- val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, schema :: Nil )
153
+ val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, schema :: Nil , scalaVersion )
153
154
val code = gen generate schema
154
155
155
156
code.head._2.unindent should equalLines(""" /**
@@ -174,7 +175,7 @@ class JsonCodecCodeGenSpec extends GCodeGenSpec("Codec") {
174
175
}
175
176
176
177
override def recordGenerateSimple = {
177
- val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil )
178
+ val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil , scalaVersion )
178
179
val record = JsonParser .ObjectTypeDefinition .parse(simpleRecordExample)
179
180
val code = gen generate record
180
181
@@ -210,7 +211,7 @@ class JsonCodecCodeGenSpec extends GCodeGenSpec("Codec") {
210
211
}
211
212
212
213
override def recordGrowZeroToOneField = {
213
- val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil )
214
+ val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil , scalaVersion )
214
215
val record = JsonParser .ObjectTypeDefinition .parse(growableAddOneFieldExample)
215
216
val code = gen generate record
216
217
@@ -246,7 +247,7 @@ class JsonCodecCodeGenSpec extends GCodeGenSpec("Codec") {
246
247
}
247
248
248
249
override def recordGrowZeroToOneToTwoFields : Unit = {
249
- val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil )
250
+ val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil , scalaVersion )
250
251
val record = JsonParser .ObjectTypeDefinition .parse(growableZeroToOneToTwoFieldsExample)
251
252
val code = gen generate record
252
253
@@ -284,7 +285,7 @@ class JsonCodecCodeGenSpec extends GCodeGenSpec("Codec") {
284
285
}
285
286
286
287
override def recordPrimitives : Unit = {
287
- val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil )
288
+ val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, Nil , scalaVersion )
288
289
val record = JsonParser .ObjectTypeDefinition .parse(primitiveTypesExample2)
289
290
val code = gen generate record
290
291
@@ -325,7 +326,7 @@ implicit lazy val primitiveTypesExample2Format: JsonFormat[_root_.primitiveTypes
325
326
326
327
override def schemaGenerateTypeReferences = {
327
328
val schema = JsonParser .Document .parse(primitiveTypesExample)
328
- val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, schema :: Nil )
329
+ val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, schema :: Nil , scalaVersion )
329
330
val code = gen generate schema
330
331
331
332
code.head._2.unindent should equalLines(""" /**
@@ -371,7 +372,7 @@ implicit lazy val primitiveTypesExample2Format: JsonFormat[_root_.primitiveTypes
371
372
372
373
override def schemaGenerateTypeReferencesNoLazy = {
373
374
val schema = JsonParser .Document .parse(primitiveTypesNoLazyExample)
374
- val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, schema :: Nil )
375
+ val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, schema :: Nil , scalaVersion )
375
376
val code = gen generate schema
376
377
377
378
code.head._2.unindent should equalLines(""" /**
@@ -408,14 +409,14 @@ implicit lazy val primitiveTypesExample2Format: JsonFormat[_root_.primitiveTypes
408
409
409
410
override def schemaGenerateComplete = {
410
411
val schema = JsonParser .Document .parse(completeExample)
411
- val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, schema :: Nil )
412
+ val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, schema :: Nil , scalaVersion )
412
413
val code = gen generate schema
413
414
code.values.mkString.unindent should equalLines(completeExampleCodeCodec.unindent)
414
415
}
415
416
416
417
override def schemaGenerateCompletePlusIndent = {
417
418
val schema = JsonParser .Document .parse(completeExample)
418
- val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, schema :: Nil )
419
+ val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, schema :: Nil , scalaVersion )
419
420
val code = gen generate schema
420
421
421
422
code.values.mkString.withoutEmptyLines should equalLines(completeExampleCodeCodec.withoutEmptyLines)
@@ -431,7 +432,7 @@ implicit lazy val primitiveTypesExample2Format: JsonFormat[_root_.primitiveTypes
431
432
| }
432
433
| ]
433
434
|} """ .stripMargin)
434
- val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, schema :: Nil )
435
+ val gen = new CodecCodeGen (codecParents, instantiateJavaLazy, javaOption, scalaArray, formatsForType, schema :: Nil , scalaVersion )
435
436
val code = gen generate schema
436
437
437
438
code.head._2.unindent should equalLines(""" /**
0 commit comments