@@ -222,7 +222,8 @@ def test_children(generate_classes):
222
222
ql .Class (name = "MyObject" , final = True ,
223
223
properties = [
224
224
ql .Property (singular = "A" , type = "int" , tablename = "my_objects" ,
225
- tableparams = ["this" , "result" , "_" ], doc = "a of this my object" ),
225
+ tableparams = ["this" , "result" , "_" ],
226
+ doc = "a of this my object" ),
226
227
ql .Property (singular = "Child1" , type = "int" , tablename = "my_objects" ,
227
228
tableparams = ["this" , "_" , "result" ], prev_child = "" ,
228
229
doc = "child 1 of this my object" ),
@@ -233,9 +234,11 @@ def test_children(generate_classes):
233
234
ql .Property (singular = "Child" , plural = "Children" , type = "int" ,
234
235
tablename = "my_object_children" ,
235
236
tableparams = ["this" , "index" , "result" ], prev_child = "Child1" ,
236
- doc = "child of this my object" , doc_plural = "children of this my object" ),
237
+ doc = "child of this my object" ,
238
+ doc_plural = "children of this my object" ),
237
239
ql .Property (singular = "C" , type = "int" , tablename = "my_object_cs" ,
238
- tableparams = ["this" , "result" ], is_optional = True , doc = "c of this my object" ),
240
+ tableparams = ["this" , "result" ], is_optional = True ,
241
+ doc = "c of this my object" ),
239
242
ql .Property (singular = "Child3" , type = "int" , tablename = "my_object_child_3s" ,
240
243
tableparams = ["this" , "result" ], is_optional = True ,
241
244
prev_child = "Child" , doc = "child 3 of this my object" ),
@@ -246,7 +249,8 @@ def test_children(generate_classes):
246
249
ql .Property (singular = "Child4" , plural = "Child4s" , type = "int" ,
247
250
tablename = "my_object_child_4s" ,
248
251
tableparams = ["this" , "index" , "result" ], is_optional = True ,
249
- prev_child = "Child3" , doc = "child 4 of this my object" , doc_plural = "child 4s of this my object" ),
252
+ prev_child = "Child3" , doc = "child 4 of this my object" ,
253
+ doc_plural = "child 4s of this my object" ),
250
254
])),
251
255
}
252
256
@@ -263,11 +267,14 @@ def test_single_properties(generate_classes):
263
267
ql .Class (name = "MyObject" , final = True ,
264
268
properties = [
265
269
ql .Property (singular = "One" , type = "x" , tablename = "my_objects" ,
266
- tableparams = ["this" , "result" , "_" , "_" ], doc = "one of this my object" ),
270
+ tableparams = ["this" , "result" , "_" , "_" ],
271
+ doc = "one of this my object" ),
267
272
ql .Property (singular = "Two" , type = "y" , tablename = "my_objects" ,
268
- tableparams = ["this" , "_" , "result" , "_" ], doc = "two of this my object" ),
273
+ tableparams = ["this" , "_" , "result" , "_" ],
274
+ doc = "two of this my object" ),
269
275
ql .Property (singular = "Three" , type = "z" , tablename = "my_objects" ,
270
- tableparams = ["this" , "_" , "_" , "result" ], doc = "three of this my object" ),
276
+ tableparams = ["this" , "_" , "_" , "result" ],
277
+ doc = "three of this my object" ),
271
278
])),
272
279
}
273
280
@@ -322,7 +329,8 @@ def test_repeated_optional_property(generate_classes, is_child, prev_child):
322
329
ql .Class (name = "MyObject" , final = True , properties = [
323
330
ql .Property (singular = "Foo" , plural = "Foos" , type = "bar" , tablename = "my_object_foos" ,
324
331
tableparams = ["this" , "index" , "result" ], is_optional = True ,
325
- prev_child = prev_child , doc = "foo of this my object" , doc_plural = "foos of this my object" ),
332
+ prev_child = prev_child , doc = "foo of this my object" ,
333
+ doc_plural = "foos of this my object" ),
326
334
])),
327
335
}
328
336
@@ -498,30 +506,38 @@ def test_test_total_properties(opts, generate_tests):
498
506
]),
499
507
]) == {
500
508
"B/B.ql" : ql .ClassTester (class_name = "B" , properties = [
501
- ql .PropertyForTest (
502
- getter = "getX" , is_single = True , type = "string" ),
503
- ql .PropertyForTest (
504
- getter = "y" , is_predicate = True , type = "predicate" ),
509
+ ql .PropertyForTest (getter = "getX" , type = "string" ),
510
+ ql .PropertyForTest (getter = "y" ),
505
511
])
506
512
}
507
513
508
514
509
515
def test_test_partial_properties (opts , generate_tests ):
510
516
write (opts .ql_test_output / "B" / "test.swift" )
511
517
assert generate_tests ([
512
- schema .Class ("A" , derived = {"B" }, properties = [
518
+ schema .Class ("A" , derived = {"B" , "C" }, properties = [
513
519
schema .OptionalProperty ("x" , "string" ),
514
520
]),
515
521
schema .Class ("B" , bases = ["A" ], properties = [
516
- schema .RepeatedProperty ("y" , "int" ),
522
+ schema .RepeatedProperty ("y" , "bool" ),
523
+ schema .RepeatedOptionalProperty ("z" , "int" ),
517
524
]),
518
525
]) == {
519
- "B/B.ql" : ql .ClassTester (class_name = "B" ),
526
+ "B/B.ql" : ql .ClassTester (class_name = "B" , properties = [
527
+ ql .PropertyForTest (getter = "hasX" ),
528
+ ql .PropertyForTest (getter = "getNumberOfYs" , type = "int" ),
529
+ ]),
520
530
"B/B_getX.ql" : ql .PropertyTester (class_name = "B" ,
521
- property = ql .PropertyForTest (getter = "getX" , type = "string" )),
531
+ property = ql .PropertyForTest (getter = "getX" , is_total = False ,
532
+ type = "string" )),
522
533
"B/B_getY.ql" : ql .PropertyTester (class_name = "B" ,
523
- property = ql .PropertyForTest (getter = "getY" , is_repeated = True ,
524
- type = "int" )),
534
+ property = ql .PropertyForTest (getter = "getY" , is_total = False ,
535
+ is_repeated = True ,
536
+ type = "bool" )),
537
+ "B/B_getZ.ql" : ql .PropertyTester (class_name = "B" ,
538
+ property = ql .PropertyForTest (getter = "getZ" , is_total = False ,
539
+ is_repeated = True ,
540
+ type = "int" )),
525
541
}
526
542
527
543
@@ -530,19 +546,20 @@ def test_test_properties_deduplicated(opts, generate_tests):
530
546
assert generate_tests ([
531
547
schema .Class ("Base" , derived = {"A" , "B" }, properties = [
532
548
schema .SingleProperty ("x" , "string" ),
533
- schema .RepeatedProperty ("y" , "int " ),
549
+ schema .RepeatedProperty ("y" , "bool " ),
534
550
]),
535
551
schema .Class ("A" , bases = ["Base" ], derived = {"Final" }),
536
552
schema .Class ("B" , bases = ["Base" ], derived = {"Final" }),
537
553
schema .Class ("Final" , bases = ["A" , "B" ]),
538
554
]) == {
539
555
"Final/Final.ql" : ql .ClassTester (class_name = "Final" , properties = [
540
- ql .PropertyForTest (
541
- getter = "getX " , is_single = True , type = "string " ),
556
+ ql .PropertyForTest (getter = "getX" , type = "string" ),
557
+ ql . PropertyForTest ( getter = "getNumberOfYs " , type = "int " ),
542
558
]),
543
559
"Final/Final_getY.ql" : ql .PropertyTester (class_name = "Final" ,
544
- property = ql .PropertyForTest (getter = "getY" , is_repeated = True ,
545
- type = "int" )),
560
+ property = ql .PropertyForTest (getter = "getY" , is_total = False ,
561
+ is_repeated = True ,
562
+ type = "bool" )),
546
563
}
547
564
548
565
@@ -692,7 +709,8 @@ def test_property_doc_abbreviations(generate_classes, abbr, expected):
692
709
"Object.qll" : (ql .Stub (name = "Object" , base_import = gen_import_prefix + "Object" ),
693
710
ql .Class (name = "Object" , final = True ,
694
711
properties = [
695
- ql .Property (singular = f"Foo{ abbr .capitalize ()} Bar" , type = "baz" , tablename = "objects" ,
712
+ ql .Property (singular = f"Foo{ abbr .capitalize ()} Bar" , type = "baz" ,
713
+ tablename = "objects" ,
696
714
tableparams = ["this" , "result" ], doc = expected_doc ),
697
715
])),
698
716
}
@@ -708,7 +726,8 @@ def test_property_doc_abbreviations_ignored_if_within_word(generate_classes, abb
708
726
"Object.qll" : (ql .Stub (name = "Object" , base_import = gen_import_prefix + "Object" ),
709
727
ql .Class (name = "Object" , final = True ,
710
728
properties = [
711
- ql .Property (singular = f"Foo{ abbr .capitalize ()} acadabraBar" , type = "baz" , tablename = "objects" ,
729
+ ql .Property (singular = f"Foo{ abbr .capitalize ()} acadabraBar" , type = "baz" ,
730
+ tablename = "objects" ,
712
731
tableparams = ["this" , "result" ], doc = expected_doc ),
713
732
])),
714
733
}
@@ -726,11 +745,13 @@ def test_repeated_property_doc_override_with_format(generate_classes):
726
745
ql .Property (singular = "X" , plural = "Xes" , type = "int" ,
727
746
tablename = "my_object_xes" ,
728
747
tableparams = ["this" , "index" , "result" ],
729
- doc = "special child of this" , doc_plural = "special children of this" ),
748
+ doc = "special child of this" ,
749
+ doc_plural = "special children of this" ),
730
750
ql .Property (singular = "Y" , plural = "Ys" , type = "int" ,
731
751
tablename = "my_object_ies" , is_optional = True ,
732
752
tableparams = ["this" , "index" , "result" ],
733
- doc = "special child of this" , doc_plural = "special children of this" ),
753
+ doc = "special child of this" ,
754
+ doc_plural = "special children of this" ),
734
755
])),
735
756
}
736
757
0 commit comments