Skip to content

Commit 21adcca

Browse files
committed
Swift: add bitwise ops to PrintAst test
1 parent 8c8f141 commit 21adcca

File tree

3 files changed

+57
-2
lines changed

3 files changed

+57
-2
lines changed

swift/ql/test/extractor-tests/expressions/expressions.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,11 @@ func test(a : A, keyPathInt : WritableKeyPath<A, Int>, keyPathB : WritableKeyPat
152152
var apply_keyPathInt = a[keyPath: keyPathInt]
153153
var apply_keyPathB = a[keyPath: keyPathB]
154154
var nested_apply = a[keyPath: keyPathB][keyPath: \B.x]
155-
}
155+
}
156+
157+
func bitwise() {
158+
_ = ~1
159+
_ = 1 & 2
160+
_ = 1 | 2
161+
_ = 1 ^ 2
162+
}

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

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4338,6 +4338,47 @@ expressions.swift:
43384338
# 154| getPattern(0): [NamedPattern] nested_apply
43394339
# 154| getElement(5): [ConcreteVarDecl] nested_apply
43404340
# 154| Type = Int
4341+
# 157| [ConcreteFuncDecl] bitwise()
4342+
# 157| InterfaceType = () -> ()
4343+
# 157| getBody(): [BraceStmt] { ... }
4344+
# 158| getElement(0): [AssignExpr] ... = ...
4345+
# 158| getDest(): [DiscardAssignmentExpr] _
4346+
# 158| getSource(): [PrefixUnaryExpr] call to ~(_:)
4347+
# 158| getFunction(): [MethodRefExpr] .~(_:)
4348+
# 158| getBase(): [TypeExpr] Int.Type
4349+
# 158| getTypeRepr(): [TypeRepr] Int
4350+
# 158| getArgument(0): [Argument] : 1
4351+
# 158| getExpr(): [IntegerLiteralExpr] 1
4352+
# 159| getElement(1): [AssignExpr] ... = ...
4353+
# 159| getDest(): [DiscardAssignmentExpr] _
4354+
# 159| getSource(): [BinaryExpr] ... .&(_:_:) ...
4355+
# 159| getFunction(): [MethodRefExpr] .&(_:_:)
4356+
# 159| getBase(): [TypeExpr] Int.Type
4357+
# 159| getTypeRepr(): [TypeRepr] Int
4358+
# 159| getArgument(0): [Argument] : 1
4359+
# 159| getExpr(): [IntegerLiteralExpr] 1
4360+
# 159| getArgument(1): [Argument] : 2
4361+
# 159| getExpr(): [IntegerLiteralExpr] 2
4362+
# 160| getElement(2): [AssignExpr] ... = ...
4363+
# 160| getDest(): [DiscardAssignmentExpr] _
4364+
# 160| getSource(): [BinaryExpr] ... .|(_:_:) ...
4365+
# 160| getFunction(): [MethodRefExpr] .|(_:_:)
4366+
# 160| getBase(): [TypeExpr] Int.Type
4367+
# 160| getTypeRepr(): [TypeRepr] Int
4368+
# 160| getArgument(0): [Argument] : 1
4369+
# 160| getExpr(): [IntegerLiteralExpr] 1
4370+
# 160| getArgument(1): [Argument] : 2
4371+
# 160| getExpr(): [IntegerLiteralExpr] 2
4372+
# 161| getElement(3): [AssignExpr] ... = ...
4373+
# 161| getDest(): [DiscardAssignmentExpr] _
4374+
# 161| getSource(): [BinaryExpr] ... .^(_:_:) ...
4375+
# 161| getFunction(): [MethodRefExpr] .^(_:_:)
4376+
# 161| getBase(): [TypeExpr] Int.Type
4377+
# 161| getTypeRepr(): [TypeRepr] Int
4378+
# 161| getArgument(0): [Argument] : 1
4379+
# 161| getExpr(): [IntegerLiteralExpr] 1
4380+
# 161| getArgument(1): [Argument] : 2
4381+
# 161| getExpr(): [IntegerLiteralExpr] 2
43414382
patterns.swift:
43424383
# 1| [ConcreteFuncDecl] basic_patterns()
43434384
# 1| InterfaceType = () -> ()

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,11 @@ func test(a : A, keyPathInt : WritableKeyPath<A, Int>, keyPathB : WritableKeyPat
152152
var apply_keyPathInt = a[keyPath: keyPathInt]
153153
var apply_keyPathB = a[keyPath: keyPathB]
154154
var nested_apply = a[keyPath: keyPathB][keyPath: \B.x]
155-
}
155+
}
156+
157+
func bitwise() {
158+
_ = ~1
159+
_ = 1 & 2
160+
_ = 1 | 2
161+
_ = 1 ^ 2
162+
}

0 commit comments

Comments
 (0)