Files
swift-mirror/test/expr/print/conditions.swift
Louis D'hauwe a89ea380a9 [ASTPrinter] Print expressions
Add new `-print-ast-decl` frontend option for only printing declarations,
to match existing behavior.
Some tests want to print the AST, but don't care about expressions.

The existing `-print-ast` option now prints function bodies and expressions.
Not all expressions are printed yet, but most common ones are.
2022-01-11 14:24:16 -08:00

39 lines
753 B
Swift

// RUN: %target-swift-frontend -print-ast %s 2>&1 | %FileCheck %s
if (5 + 5) == 10 {
}
// CHECK: if (5 + 5) == 10 {
// CHECK: }
if (5 + 5) == 9 {
} else if (5 + 5) == 10 {
} else {
}
// CHECK: if (5 + 5) == 9 {
// CHECK: } else if (5 + 5) == 10 {
// CHECK: } else {
// CHECK: }
guard (5 + 5) == 10 else {
}
// CHECK: guard (5 + 5) == 10 else {
// CHECK: }
var a = 0
// CHECK: @_hasInitialValue internal var a: Int = 0
// Note: the AST doesn't store whitespace,
// so the output doesn't always match the input.
while a < 10 { a += 1 }
// CHECK: while a < 10 {
// CHECK: a += 1
// CHECK: }
var b = 0
repeat {
b += 1
} while b < 10
// CHECK: @_hasInitialValue internal var b: Int = 0
// CHECK: repeat {
// CHECK: b += 1
// CHECK: } while b < 10