forked from github/codeql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
swift/ql/test/library-tests/elements/type/numerictype/numeric.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
|
||
typealias MyFloat = Float | ||
|
||
func test() { | ||
var f1: Float | ||
let f2 = 123.456 | ||
let f3 = f2 | ||
var f4: Float? | ||
var f5: MyFloat | ||
var f6: MyFloat? | ||
|
||
var d: Double | ||
|
||
var c: Character | ||
|
||
var i1: Int | ||
let i2 = 123 | ||
let i3 = 0xFFFF | ||
var i4: Int8 | ||
var i5: Int16 | ||
var i6: Int32 | ||
var i7: Int64 | ||
|
||
var u1: UInt | ||
var u2: UInt8 | ||
var u3: UInt16 | ||
var u4: UInt32 | ||
var u5: UInt64 | ||
|
||
var b1: Bool | ||
let b2 = true | ||
} |
22 changes: 22 additions & 0 deletions
22
swift/ql/test/library-tests/elements/type/numerictype/numerictype.expected
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
| numeric.swift:5:6:5:6 | f1 | Float | FloatingPointType, NumericType | | ||
| numeric.swift:6:6:6:6 | f2 | Double | FloatingPointType, NumericType | | ||
| numeric.swift:7:6:7:6 | f3 | Double | FloatingPointType, NumericType | | ||
| numeric.swift:8:6:8:6 | f4 | Float? | | | ||
| numeric.swift:9:6:9:6 | f5 | MyFloat | | | ||
| numeric.swift:10:6:10:6 | f6 | MyFloat? | | | ||
| numeric.swift:12:6:12:6 | d | Double | FloatingPointType, NumericType | | ||
| numeric.swift:14:6:14:6 | c | Character | CharacterType | | ||
| numeric.swift:16:6:16:6 | i1 | Int | IntegralType, NumericType | | ||
| numeric.swift:17:6:17:6 | i2 | Int | IntegralType, NumericType | | ||
| numeric.swift:18:6:18:6 | i3 | Int | IntegralType, NumericType | | ||
| numeric.swift:19:6:19:6 | i4 | Int8 | IntegralType, NumericType | | ||
| numeric.swift:20:6:20:6 | i5 | Int16 | IntegralType, NumericType | | ||
| numeric.swift:21:6:21:6 | i6 | Int32 | IntegralType, NumericType | | ||
| numeric.swift:22:6:22:6 | i7 | Int64 | IntegralType, NumericType | | ||
| numeric.swift:24:6:24:6 | u1 | UInt | IntegralType, NumericType | | ||
| numeric.swift:25:6:25:6 | u2 | UInt8 | IntegralType, NumericType | | ||
| numeric.swift:26:6:26:6 | u3 | UInt16 | IntegralType, NumericType | | ||
| numeric.swift:27:6:27:6 | u4 | UInt32 | IntegralType, NumericType | | ||
| numeric.swift:28:6:28:6 | u5 | UInt64 | IntegralType, NumericType | | ||
| numeric.swift:30:6:30:6 | b1 | Bool | BoolType | | ||
| numeric.swift:31:6:31:6 | b2 | Bool | BoolType | |
19 changes: 19 additions & 0 deletions
19
swift/ql/test/library-tests/elements/type/numerictype/numerictype.ql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import swift | ||
|
||
string describe(Type t) { | ||
t instanceof FloatingPointType and result = "FloatingPointType" | ||
or | ||
t instanceof CharacterType and result = "CharacterType" | ||
or | ||
t instanceof IntegralType and result = "IntegralType" | ||
or | ||
t instanceof BoolType and result = "BoolType" | ||
or | ||
t instanceof NumericType and result = "NumericType" | ||
} | ||
|
||
from VarDecl v, Type t | ||
where | ||
v.getLocation().getFile().getBaseName() != "" and | ||
t = v.getType() | ||
select v, t.toString(), concat(describe(t), ", ") |