Skip to content

Commit 7053c62

Browse files
committed
Swift: update and sync tests
1 parent 65fbcc5 commit 7053c62

File tree

3 files changed

+133
-6
lines changed

3 files changed

+133
-6
lines changed

swift/ql/test/library-tests/ast/PrintAst.expected

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3206,6 +3206,90 @@ cfg.swift:
32063206
# 519| getElement(6): [ReturnStmt] return ...
32073207
# 519| getResult(): [DeclRefExpr] x
32083208
# 519| getResult().getFullyConverted(): [LoadExpr] (Int) ...
3209+
# 522| [NamedFunction] testAsyncFor()
3210+
# 522| InterfaceType = () async -> ()
3211+
# 522| getBody(): [BraceStmt] { ... }
3212+
# 523| getVariable(0): [ConcreteVarDecl] stream
3213+
# 523| Type = AsyncStream<Int>
3214+
# 523| getElement(0): [PatternBindingDecl] var ... = ...
3215+
# 523| getInit(0): [CallExpr] call to AsyncStream<Element>.init(_:bufferingPolicy:_:)
3216+
# 523| getFunction(): [MethodLookupExpr] AsyncStream<Element>.init(_:bufferingPolicy:_:)
3217+
# 523| getBase(): [TypeExpr] AsyncStream<Int>.Type
3218+
# 523| getTypeRepr(): [TypeRepr] AsyncStream<Int>
3219+
# 523| getMethodRef(): [DeclRefExpr] AsyncStream<Element>.init(_:bufferingPolicy:_:)
3220+
# 523| getArgument(0): [Argument] : Int.Type
3221+
# 523| getExpr(): [TypeExpr] Int.Type
3222+
# 523| getTypeRepr(): [TypeRepr] Int
3223+
# 523| getExpr().getFullyConverted(): [DotSelfExpr] .self
3224+
# 523| getArgument(1): [Argument] bufferingPolicy: call to ...
3225+
# 523| getExpr(): [CallExpr] call to ...
3226+
# 523| getFunction(): [MethodLookupExpr] .bufferingNewest
3227+
# 523| getBase(): [TypeExpr] AsyncStream<Int>.Continuation.BufferingPolicy.Type
3228+
# 523| getTypeRepr(): [TypeRepr] AsyncStream<Int>.Continuation.BufferingPolicy
3229+
# 523| getMethodRef(): [DeclRefExpr] bufferingNewest
3230+
# 523| getArgument(0): [Argument] : 5
3231+
# 523| getExpr(): [IntegerLiteralExpr] 5
3232+
# 523| getArgument(2): [Argument] : { ... }
3233+
# 523| getExpr(): [ExplicitClosureExpr] { ... }
3234+
# 524| getParam(0): [ParamDecl] continuation
3235+
# 524| Type = AsyncStream<Int>.Continuation
3236+
# 523| getBody(): [BraceStmt] { ... }
3237+
# 525| getElement(0): [BraceStmt] { ... }
3238+
# 525| getElement(0): [CallExpr] call to detached(priority:operation:)
3239+
# 525| getFunction(): [MethodLookupExpr] .detached(priority:operation:)
3240+
# 525| getBase(): [TypeExpr] Task<(), Never>.Type
3241+
# 525| getTypeRepr(): [TypeRepr] Task<(), Never>
3242+
# 525| getMethodRef(): [DeclRefExpr] detached(priority:operation:)
3243+
# 525| getArgument(0): [Argument] priority: default priority
3244+
# 525| getExpr(): [DefaultArgumentExpr] default priority
3245+
# 525| getArgument(1): [Argument] operation: { ... }
3246+
# 525| getExpr(): [ExplicitClosureExpr] { ... }
3247+
# 525| getBody(): [BraceStmt] { ... }
3248+
# 526| getElement(0): [ForEachStmt] for ... in ... { ... }
3249+
# 526| getPattern(): [NamedPattern] i
3250+
# 526| getSequence(): [BinaryExpr] ... ....(_:_:) ...
3251+
# 526| getFunction(): [MethodLookupExpr] ....(_:_:)
3252+
# 526| getBase(): [TypeExpr] Int.Type
3253+
# 526| getTypeRepr(): [TypeRepr] Int
3254+
# 526| getMethodRef(): [DeclRefExpr] ...(_:_:)
3255+
# 526| getArgument(0): [Argument] : 1
3256+
# 526| getExpr(): [IntegerLiteralExpr] 1
3257+
# 526| getArgument(1): [Argument] : 100
3258+
# 526| getExpr(): [IntegerLiteralExpr] 100
3259+
# 526| getBody(): [BraceStmt] { ... }
3260+
# 527| getElement(0): [CallExpr] call to yield(_:)
3261+
# 527| getFunction(): [MethodLookupExpr] .yield(_:)
3262+
# 527| getBase(): [DeclRefExpr] continuation
3263+
# 527| getMethodRef(): [DeclRefExpr] yield(_:)
3264+
# 527| getArgument(0): [Argument] : i
3265+
# 527| getExpr(): [DeclRefExpr] i
3266+
# 529| getElement(1): [CallExpr] call to finish()
3267+
# 529| getFunction(): [MethodLookupExpr] .finish()
3268+
# 529| getBase(): [DeclRefExpr] continuation
3269+
# 529| getMethodRef(): [DeclRefExpr] finish()
3270+
# 527| getCapture(0): [CapturedDecl] continuation
3271+
# 525| getElement(1): [ReturnStmt] return
3272+
# 523| getPattern(0): [NamedPattern] stream
3273+
# 533| getElement(1): [ForEachStmt] for ... in ... { ... }
3274+
# 533| getPattern(): [NamedPattern] i
3275+
# 533| getSequence(): [DeclRefExpr] stream
3276+
# 533| getBody(): [BraceStmt] { ... }
3277+
# 534| getElement(0): [CallExpr] call to print(_:separator:terminator:)
3278+
# 534| getFunction(): [DeclRefExpr] print(_:separator:terminator:)
3279+
# 534| getArgument(0): [Argument] : [...]
3280+
# 534| getExpr(): [VarargExpansionExpr] [...]
3281+
# 534| getSubExpr(): [ArrayExpr] [...]
3282+
# 534| getElement(0): [DeclRefExpr] i
3283+
# 534| getElement(0).getFullyConverted(): [ErasureExpr] (Any) ...
3284+
# 534| getArgument(1): [Argument] separator: default separator
3285+
# 534| getExpr(): [DefaultArgumentExpr] default separator
3286+
# 534| getArgument(2): [Argument] terminator: default terminator
3287+
# 534| getExpr(): [DefaultArgumentExpr] default terminator
3288+
# 525| [NilLiteralExpr] nil
3289+
# 526| [ConcreteVarDecl] i
3290+
# 526| Type = Int
3291+
# 533| [ConcreteVarDecl] i
3292+
# 533| Type = Int
32093293
declarations.swift:
32103294
# 1| [StructDecl] Foo
32113295
# 2| getMember(0): [PatternBindingDecl] var ... = ...

swift/ql/test/library-tests/ast/cfg.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,3 +518,19 @@ func testAvailable() -> Int {
518518

519519
return x
520520
}
521+
522+
func testAsyncFor () async {
523+
var stream = AsyncStream(Int.self, bufferingPolicy: .bufferingNewest(5), {
524+
continuation in
525+
Task.detached {
526+
for i in 1...100 {
527+
continuation.yield(i)
528+
}
529+
continuation.finish()
530+
}
531+
})
532+
533+
for try await i in stream {
534+
print(i)
535+
}
536+
}

swift/ql/test/library-tests/controlflow/graph/Cfg.expected

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,26 +1458,44 @@ cfg.swift:
14581458
# 141| case ...
14591459
#-----| -> =~ ...
14601460

1461-
# 141| 0
1461+
# 141| $match
1462+
#-----| -> ... ~=(_:_:) ...
1463+
1464+
# 141| ... ~=(_:_:) ...
14621465
#-----| -> =~ ...
14631466

1467+
# 141| 0
1468+
#-----| -> $match
1469+
14641470
# 141| =~ ...
1465-
#-----| -> 0
1471+
#-----| -> ~=(_:_:)
14661472

14671473
# 141| =~ ...
14681474
#-----| no-match -> =~ ...
14691475
#-----| match -> true
14701476

1471-
# 141| 1
1477+
# 141| ~=(_:_:)
1478+
#-----| -> 0
1479+
1480+
# 141| $match
1481+
#-----| -> ... ~=(_:_:) ...
1482+
1483+
# 141| ... ~=(_:_:) ...
14721484
#-----| -> =~ ...
14731485

1486+
# 141| 1
1487+
#-----| -> $match
1488+
14741489
# 141| =~ ...
1475-
#-----| -> 1
1490+
#-----| -> ~=(_:_:)
14761491

14771492
# 141| =~ ...
14781493
#-----| match -> true
14791494
#-----| no-match -> case ...
14801495

1496+
# 141| ~=(_:_:)
1497+
#-----| -> 1
1498+
14811499
# 142| return ...
14821500
#-----| return -> exit patterns(x:) (normal)
14831501

@@ -1487,16 +1505,25 @@ cfg.swift:
14871505
# 144| case ...
14881506
#-----| -> =~ ... where ...
14891507

1508+
# 144| $match
1509+
#-----| -> ... ~=(_:_:) ...
1510+
1511+
# 144| ... ~=(_:_:) ...
1512+
#-----| -> =~ ...
1513+
14901514
# 144| =~ ...
14911515
#-----| match, no-match -> ... .&&(_:_:) ...
14921516
#-----| no-match -> case ...
14931517

14941518
# 144| x
1495-
#-----| -> =~ ...
1519+
#-----| -> $match
14961520

1497-
# 144| =~ ... where ...
1521+
# 144| ~=(_:_:)
14981522
#-----| -> x
14991523

1524+
# 144| =~ ... where ...
1525+
#-----| -> ~=(_:_:)
1526+
15001527
# 144| ... .&&(_:_:) ...
15011528

15021529
# 146| _

0 commit comments

Comments
 (0)