Add switch end-to-end tests.
This CL adds end-to-end tests for switch statements.
Bug: tint:1718
Change-Id: Id123d7ed43637d1662ada6f46973b3e181b6f4c7
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/162266
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/test/tint/switch/switch.wgsl b/test/tint/switch/switch.wgsl
new file mode 100644
index 0000000..cbac291
--- /dev/null
+++ b/test/tint/switch/switch.wgsl
@@ -0,0 +1,15 @@
+fn a() {
+ var a = 0;
+ switch(a) {
+ case 0: {
+ break;
+ }
+ case 1: {
+ return;
+ }
+ default: {
+ a += 2;
+ break;
+ }
+ }
+}
diff --git a/test/tint/switch/switch.wgsl.expected.dxc.hlsl b/test/tint/switch/switch.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..bd4438a
--- /dev/null
+++ b/test/tint/switch/switch.wgsl.expected.dxc.hlsl
@@ -0,0 +1,21 @@
+[numthreads(1, 1, 1)]
+void unused_entry_point() {
+ return;
+}
+
+void a() {
+ int a_1 = 0;
+ switch(a_1) {
+ case 0: {
+ break;
+ }
+ case 1: {
+ return;
+ break;
+ }
+ default: {
+ a_1 = (a_1 + 2);
+ break;
+ }
+ }
+}
diff --git a/test/tint/switch/switch.wgsl.expected.fxc.hlsl b/test/tint/switch/switch.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..bd4438a
--- /dev/null
+++ b/test/tint/switch/switch.wgsl.expected.fxc.hlsl
@@ -0,0 +1,21 @@
+[numthreads(1, 1, 1)]
+void unused_entry_point() {
+ return;
+}
+
+void a() {
+ int a_1 = 0;
+ switch(a_1) {
+ case 0: {
+ break;
+ }
+ case 1: {
+ return;
+ break;
+ }
+ default: {
+ a_1 = (a_1 + 2);
+ break;
+ }
+ }
+}
diff --git a/test/tint/switch/switch.wgsl.expected.glsl b/test/tint/switch/switch.wgsl.expected.glsl
new file mode 100644
index 0000000..07b97a1
--- /dev/null
+++ b/test/tint/switch/switch.wgsl.expected.glsl
@@ -0,0 +1,23 @@
+#version 310 es
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void unused_entry_point() {
+ return;
+}
+void a() {
+ int a_1 = 0;
+ switch(a_1) {
+ case 0: {
+ break;
+ }
+ case 1: {
+ return;
+ break;
+ }
+ default: {
+ a_1 = (a_1 + 2);
+ break;
+ }
+ }
+}
+
diff --git a/test/tint/switch/switch.wgsl.expected.ir.msl b/test/tint/switch/switch.wgsl.expected.ir.msl
new file mode 100644
index 0000000..44b5abc
--- /dev/null
+++ b/test/tint/switch/switch.wgsl.expected.ir.msl
@@ -0,0 +1,21 @@
+#include <metal_stdlib>
+using namespace metal;
+
+void a() {
+ int a = 0;
+ switch(a) {
+ case 0:
+ {
+ break;
+ }
+ case 1:
+ {
+ return;
+ }
+ default:
+ {
+ a = (a + 2);
+ break;
+ }
+ }
+}
diff --git a/test/tint/switch/switch.wgsl.expected.msl b/test/tint/switch/switch.wgsl.expected.msl
new file mode 100644
index 0000000..e25b13d
--- /dev/null
+++ b/test/tint/switch/switch.wgsl.expected.msl
@@ -0,0 +1,20 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void a() {
+ int a_1 = 0;
+ switch(a_1) {
+ case 0: {
+ break;
+ }
+ case 1: {
+ return;
+ break;
+ }
+ default: {
+ a_1 = as_type<int>((as_type<uint>(a_1) + as_type<uint>(2)));
+ break;
+ }
+ }
+}
+
diff --git a/test/tint/switch/switch.wgsl.expected.spvasm b/test/tint/switch/switch.wgsl.expected.spvasm
new file mode 100644
index 0000000..be19bff
--- /dev/null
+++ b/test/tint/switch/switch.wgsl.expected.spvasm
@@ -0,0 +1,48 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 24
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
+ OpExecutionMode %unused_entry_point LocalSize 1 1 1
+ OpName %unused_entry_point "unused_entry_point"
+ OpName %a "a"
+ OpName %tint_return_flag "tint_return_flag"
+ OpName %a_1 "a_1"
+ %void = OpTypeVoid
+ %1 = OpTypeFunction %void
+ %bool = OpTypeBool
+%_ptr_Function_bool = OpTypePointer Function %bool
+ %10 = OpConstantNull %bool
+ %int = OpTypeInt 32 1
+ %12 = OpConstantNull %int
+%_ptr_Function_int = OpTypePointer Function %int
+ %true = OpConstantTrue %bool
+ %int_2 = OpConstant %int 2
+%unused_entry_point = OpFunction %void None %1
+ %4 = OpLabel
+ OpReturn
+ OpFunctionEnd
+ %a = OpFunction %void None %1
+ %6 = OpLabel
+%tint_return_flag = OpVariable %_ptr_Function_bool Function %10
+ %a_1 = OpVariable %_ptr_Function_int Function %12
+ OpStore %a_1 %12
+ %16 = OpLoad %int %a_1
+ OpSelectionMerge %15 None
+ OpSwitch %16 %17 0 %18 1 %19
+ %18 = OpLabel
+ OpBranch %15
+ %19 = OpLabel
+ OpStore %tint_return_flag %true
+ OpBranch %15
+ %17 = OpLabel
+ %21 = OpLoad %int %a_1
+ %23 = OpIAdd %int %21 %int_2
+ OpStore %a_1 %23
+ OpBranch %15
+ %15 = OpLabel
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/switch/switch.wgsl.expected.wgsl b/test/tint/switch/switch.wgsl.expected.wgsl
new file mode 100644
index 0000000..72475f7
--- /dev/null
+++ b/test/tint/switch/switch.wgsl.expected.wgsl
@@ -0,0 +1,15 @@
+fn a() {
+ var a = 0;
+ switch(a) {
+ case 0: {
+ break;
+ }
+ case 1: {
+ return;
+ }
+ default: {
+ a += 2;
+ break;
+ }
+ }
+}
diff --git a/test/tint/switch/switch_multi_selector.wgsl b/test/tint/switch/switch_multi_selector.wgsl
new file mode 100644
index 0000000..327fc0e
--- /dev/null
+++ b/test/tint/switch/switch_multi_selector.wgsl
@@ -0,0 +1,11 @@
+fn a() {
+ var a = 0;
+ switch(a) {
+ case 0, 2, 4: {
+ break;
+ }
+ case 1, default: {
+ return;
+ }
+ }
+}
diff --git a/test/tint/switch/switch_multi_selector.wgsl.expected.dxc.hlsl b/test/tint/switch/switch_multi_selector.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..60665e5
--- /dev/null
+++ b/test/tint/switch/switch_multi_selector.wgsl.expected.dxc.hlsl
@@ -0,0 +1,20 @@
+[numthreads(1, 1, 1)]
+void unused_entry_point() {
+ return;
+}
+
+void a() {
+ int a_1 = 0;
+ switch(a_1) {
+ case 0:
+ case 2:
+ case 4: {
+ break;
+ }
+ case 1:
+ default: {
+ return;
+ break;
+ }
+ }
+}
diff --git a/test/tint/switch/switch_multi_selector.wgsl.expected.fxc.hlsl b/test/tint/switch/switch_multi_selector.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..60665e5
--- /dev/null
+++ b/test/tint/switch/switch_multi_selector.wgsl.expected.fxc.hlsl
@@ -0,0 +1,20 @@
+[numthreads(1, 1, 1)]
+void unused_entry_point() {
+ return;
+}
+
+void a() {
+ int a_1 = 0;
+ switch(a_1) {
+ case 0:
+ case 2:
+ case 4: {
+ break;
+ }
+ case 1:
+ default: {
+ return;
+ break;
+ }
+ }
+}
diff --git a/test/tint/switch/switch_multi_selector.wgsl.expected.glsl b/test/tint/switch/switch_multi_selector.wgsl.expected.glsl
new file mode 100644
index 0000000..685241f
--- /dev/null
+++ b/test/tint/switch/switch_multi_selector.wgsl.expected.glsl
@@ -0,0 +1,22 @@
+#version 310 es
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void unused_entry_point() {
+ return;
+}
+void a() {
+ int a_1 = 0;
+ switch(a_1) {
+ case 0:
+ case 2:
+ case 4: {
+ break;
+ }
+ case 1:
+ default: {
+ return;
+ break;
+ }
+ }
+}
+
diff --git a/test/tint/switch/switch_multi_selector.wgsl.expected.ir.msl b/test/tint/switch/switch_multi_selector.wgsl.expected.ir.msl
new file mode 100644
index 0000000..baf66ae
--- /dev/null
+++ b/test/tint/switch/switch_multi_selector.wgsl.expected.ir.msl
@@ -0,0 +1,19 @@
+#include <metal_stdlib>
+using namespace metal;
+
+void a() {
+ int a = 0;
+ switch(a) {
+ case 0:
+ case 2:
+ case 4:
+ {
+ break;
+ }
+ case 1:
+ default:
+ {
+ return;
+ }
+ }
+}
diff --git a/test/tint/switch/switch_multi_selector.wgsl.expected.msl b/test/tint/switch/switch_multi_selector.wgsl.expected.msl
new file mode 100644
index 0000000..e5542b4
--- /dev/null
+++ b/test/tint/switch/switch_multi_selector.wgsl.expected.msl
@@ -0,0 +1,19 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void a() {
+ int a_1 = 0;
+ switch(a_1) {
+ case 0:
+ case 2:
+ case 4: {
+ break;
+ }
+ case 1:
+ default: {
+ return;
+ break;
+ }
+ }
+}
+
diff --git a/test/tint/switch/switch_multi_selector.wgsl.expected.spvasm b/test/tint/switch/switch_multi_selector.wgsl.expected.spvasm
new file mode 100644
index 0000000..84845e0
--- /dev/null
+++ b/test/tint/switch/switch_multi_selector.wgsl.expected.spvasm
@@ -0,0 +1,42 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 20
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
+ OpExecutionMode %unused_entry_point LocalSize 1 1 1
+ OpName %unused_entry_point "unused_entry_point"
+ OpName %a "a"
+ OpName %tint_return_flag "tint_return_flag"
+ OpName %a_1 "a_1"
+ %void = OpTypeVoid
+ %1 = OpTypeFunction %void
+ %bool = OpTypeBool
+%_ptr_Function_bool = OpTypePointer Function %bool
+ %10 = OpConstantNull %bool
+ %int = OpTypeInt 32 1
+ %12 = OpConstantNull %int
+%_ptr_Function_int = OpTypePointer Function %int
+ %true = OpConstantTrue %bool
+%unused_entry_point = OpFunction %void None %1
+ %4 = OpLabel
+ OpReturn
+ OpFunctionEnd
+ %a = OpFunction %void None %1
+ %6 = OpLabel
+%tint_return_flag = OpVariable %_ptr_Function_bool Function %10
+ %a_1 = OpVariable %_ptr_Function_int Function %12
+ OpStore %a_1 %12
+ %16 = OpLoad %int %a_1
+ OpSelectionMerge %15 None
+ OpSwitch %16 %17 0 %18 2 %18 4 %18 1 %17
+ %18 = OpLabel
+ OpBranch %15
+ %17 = OpLabel
+ OpStore %tint_return_flag %true
+ OpBranch %15
+ %15 = OpLabel
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/switch/switch_multi_selector.wgsl.expected.wgsl b/test/tint/switch/switch_multi_selector.wgsl.expected.wgsl
new file mode 100644
index 0000000..cc64089
--- /dev/null
+++ b/test/tint/switch/switch_multi_selector.wgsl.expected.wgsl
@@ -0,0 +1,11 @@
+fn a() {
+ var a = 0;
+ switch(a) {
+ case 0, 2, 4: {
+ break;
+ }
+ case 1, default: {
+ return;
+ }
+ }
+}
diff --git a/test/tint/switch/switch_nested.wgsl b/test/tint/switch/switch_nested.wgsl
new file mode 100644
index 0000000..342595d
--- /dev/null
+++ b/test/tint/switch/switch_nested.wgsl
@@ -0,0 +1,29 @@
+fn a() {
+ var a = 0;
+ switch(a) {
+ case 0, 2, 4: {
+ var b = 3u;
+ switch(b) {
+ case 0: {
+ break;
+ }
+ case 1, 2, 3, default: {
+ var c = 123u;
+ switch(c) {
+ case 0: {
+ break;
+ }
+ default: {
+ return;
+ }
+ }
+ return;
+ }
+ }
+ break;
+ }
+ case 1, default: {
+ return;
+ }
+ }
+}
diff --git a/test/tint/switch/switch_nested.wgsl.expected.dxc.hlsl b/test/tint/switch/switch_nested.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..0e772a6ff
--- /dev/null
+++ b/test/tint/switch/switch_nested.wgsl.expected.dxc.hlsl
@@ -0,0 +1,43 @@
+[numthreads(1, 1, 1)]
+void unused_entry_point() {
+ return;
+}
+
+void a() {
+ int a_1 = 0;
+ switch(a_1) {
+ case 0:
+ case 2:
+ case 4: {
+ uint b = 3u;
+ switch(b) {
+ case 0u: {
+ break;
+ }
+ case 1u:
+ case 2u:
+ case 3u:
+ default: {
+ uint c = 123u;
+ switch(c) {
+ case 0u: {
+ break;
+ }
+ default: {
+ return;
+ break;
+ }
+ }
+ return;
+ break;
+ }
+ }
+ break;
+ }
+ case 1:
+ default: {
+ return;
+ break;
+ }
+ }
+}
diff --git a/test/tint/switch/switch_nested.wgsl.expected.fxc.hlsl b/test/tint/switch/switch_nested.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..0e772a6ff
--- /dev/null
+++ b/test/tint/switch/switch_nested.wgsl.expected.fxc.hlsl
@@ -0,0 +1,43 @@
+[numthreads(1, 1, 1)]
+void unused_entry_point() {
+ return;
+}
+
+void a() {
+ int a_1 = 0;
+ switch(a_1) {
+ case 0:
+ case 2:
+ case 4: {
+ uint b = 3u;
+ switch(b) {
+ case 0u: {
+ break;
+ }
+ case 1u:
+ case 2u:
+ case 3u:
+ default: {
+ uint c = 123u;
+ switch(c) {
+ case 0u: {
+ break;
+ }
+ default: {
+ return;
+ break;
+ }
+ }
+ return;
+ break;
+ }
+ }
+ break;
+ }
+ case 1:
+ default: {
+ return;
+ break;
+ }
+ }
+}
diff --git a/test/tint/switch/switch_nested.wgsl.expected.glsl b/test/tint/switch/switch_nested.wgsl.expected.glsl
new file mode 100644
index 0000000..09ca982
--- /dev/null
+++ b/test/tint/switch/switch_nested.wgsl.expected.glsl
@@ -0,0 +1,45 @@
+#version 310 es
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void unused_entry_point() {
+ return;
+}
+void a() {
+ int a_1 = 0;
+ switch(a_1) {
+ case 0:
+ case 2:
+ case 4: {
+ uint b = 3u;
+ switch(b) {
+ case 0u: {
+ break;
+ }
+ case 1u:
+ case 2u:
+ case 3u:
+ default: {
+ uint c = 123u;
+ switch(c) {
+ case 0u: {
+ break;
+ }
+ default: {
+ return;
+ break;
+ }
+ }
+ return;
+ break;
+ }
+ }
+ break;
+ }
+ case 1:
+ default: {
+ return;
+ break;
+ }
+ }
+}
+
diff --git a/test/tint/switch/switch_nested.wgsl.expected.ir.msl b/test/tint/switch/switch_nested.wgsl.expected.ir.msl
new file mode 100644
index 0000000..ac17bcd
--- /dev/null
+++ b/test/tint/switch/switch_nested.wgsl.expected.ir.msl
@@ -0,0 +1,44 @@
+#include <metal_stdlib>
+using namespace metal;
+
+void a() {
+ int a = 0;
+ switch(a) {
+ case 0:
+ case 2:
+ case 4:
+ {
+ uint b = 3u;
+ switch(b) {
+ case 0u:
+ {
+ break;
+ }
+ case 1u:
+ case 2u:
+ case 3u:
+ default:
+ {
+ uint c = 123u;
+ switch(c) {
+ case 0u:
+ {
+ break;
+ }
+ default:
+ {
+ return;
+ }
+ }
+ return;
+ }
+ }
+ break;
+ }
+ case 1:
+ default:
+ {
+ return;
+ }
+ }
+}
diff --git a/test/tint/switch/switch_nested.wgsl.expected.msl b/test/tint/switch/switch_nested.wgsl.expected.msl
new file mode 100644
index 0000000..a5063ac
--- /dev/null
+++ b/test/tint/switch/switch_nested.wgsl.expected.msl
@@ -0,0 +1,42 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void a() {
+ int a_1 = 0;
+ switch(a_1) {
+ case 0:
+ case 2:
+ case 4: {
+ uint b = 3u;
+ switch(b) {
+ case 0u: {
+ break;
+ }
+ case 1u:
+ case 2u:
+ case 3u:
+ default: {
+ uint c = 123u;
+ switch(c) {
+ case 0u: {
+ break;
+ }
+ default: {
+ return;
+ break;
+ }
+ }
+ return;
+ break;
+ }
+ }
+ break;
+ }
+ case 1:
+ default: {
+ return;
+ break;
+ }
+ }
+}
+
diff --git a/test/tint/switch/switch_nested.wgsl.expected.spvasm b/test/tint/switch/switch_nested.wgsl.expected.spvasm
new file mode 100644
index 0000000..ffd10cb
--- /dev/null
+++ b/test/tint/switch/switch_nested.wgsl.expected.spvasm
@@ -0,0 +1,83 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 41
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
+ OpExecutionMode %unused_entry_point LocalSize 1 1 1
+ OpName %unused_entry_point "unused_entry_point"
+ OpName %a "a"
+ OpName %tint_return_flag "tint_return_flag"
+ OpName %a_1 "a_1"
+ OpName %b "b"
+ OpName %c "c"
+ %void = OpTypeVoid
+ %1 = OpTypeFunction %void
+ %bool = OpTypeBool
+%_ptr_Function_bool = OpTypePointer Function %bool
+ %10 = OpConstantNull %bool
+ %int = OpTypeInt 32 1
+ %12 = OpConstantNull %int
+%_ptr_Function_int = OpTypePointer Function %int
+ %uint = OpTypeInt 32 0
+ %uint_3 = OpConstant %uint 3
+%_ptr_Function_uint = OpTypePointer Function %uint
+ %23 = OpConstantNull %uint
+ %uint_123 = OpConstant %uint 123
+ %true = OpConstantTrue %bool
+%unused_entry_point = OpFunction %void None %1
+ %4 = OpLabel
+ OpReturn
+ OpFunctionEnd
+ %a = OpFunction %void None %1
+ %6 = OpLabel
+%tint_return_flag = OpVariable %_ptr_Function_bool Function %10
+ %a_1 = OpVariable %_ptr_Function_int Function %12
+ %b = OpVariable %_ptr_Function_uint Function %23
+ %c = OpVariable %_ptr_Function_uint Function %23
+ OpStore %a_1 %12
+ %16 = OpLoad %int %a_1
+ OpSelectionMerge %15 None
+ OpSwitch %16 %17 0 %18 2 %18 4 %18 1 %17
+ %18 = OpLabel
+ OpStore %b %uint_3
+ %25 = OpLoad %uint %b
+ OpSelectionMerge %24 None
+ OpSwitch %25 %26 0 %27 1 %26 2 %26 3 %26
+ %27 = OpLabel
+ OpBranch %24
+ %26 = OpLabel
+ OpStore %c %uint_123
+ %31 = OpLoad %uint %c
+ OpSelectionMerge %30 None
+ OpSwitch %31 %32 0 %33
+ %33 = OpLabel
+ OpBranch %30
+ %32 = OpLabel
+ OpStore %tint_return_flag %true
+ OpBranch %30
+ %30 = OpLabel
+ %35 = OpLoad %bool %tint_return_flag
+ OpSelectionMerge %36 None
+ OpBranchConditional %35 %37 %36
+ %37 = OpLabel
+ OpBranch %24
+ %36 = OpLabel
+ OpStore %tint_return_flag %true
+ OpBranch %24
+ %24 = OpLabel
+ %38 = OpLoad %bool %tint_return_flag
+ OpSelectionMerge %39 None
+ OpBranchConditional %38 %40 %39
+ %40 = OpLabel
+ OpBranch %15
+ %39 = OpLabel
+ OpBranch %15
+ %17 = OpLabel
+ OpStore %tint_return_flag %true
+ OpBranch %15
+ %15 = OpLabel
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/switch/switch_nested.wgsl.expected.wgsl b/test/tint/switch/switch_nested.wgsl.expected.wgsl
new file mode 100644
index 0000000..56d18be
--- /dev/null
+++ b/test/tint/switch/switch_nested.wgsl.expected.wgsl
@@ -0,0 +1,29 @@
+fn a() {
+ var a = 0;
+ switch(a) {
+ case 0, 2, 4: {
+ var b = 3u;
+ switch(b) {
+ case 0: {
+ break;
+ }
+ case 1, 2, 3, default: {
+ var c = 123u;
+ switch(c) {
+ case 0: {
+ break;
+ }
+ default: {
+ return;
+ }
+ }
+ return;
+ }
+ }
+ break;
+ }
+ case 1, default: {
+ return;
+ }
+ }
+}
diff --git a/test/tint/switch/switch_only_default.wgsl b/test/tint/switch/switch_only_default.wgsl
new file mode 100644
index 0000000..8871ae0
--- /dev/null
+++ b/test/tint/switch/switch_only_default.wgsl
@@ -0,0 +1,8 @@
+fn a() {
+ var a = 0;
+ switch(a) {
+ default: {
+ return;
+ }
+ }
+}
diff --git a/test/tint/switch/switch_only_default.wgsl.expected.dxc.hlsl b/test/tint/switch/switch_only_default.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..07fc072
--- /dev/null
+++ b/test/tint/switch/switch_only_default.wgsl.expected.dxc.hlsl
@@ -0,0 +1,11 @@
+[numthreads(1, 1, 1)]
+void unused_entry_point() {
+ return;
+}
+
+void a() {
+ int a_1 = 0;
+ do {
+ return;
+ } while (false);
+}
diff --git a/test/tint/switch/switch_only_default.wgsl.expected.fxc.hlsl b/test/tint/switch/switch_only_default.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..07fc072
--- /dev/null
+++ b/test/tint/switch/switch_only_default.wgsl.expected.fxc.hlsl
@@ -0,0 +1,11 @@
+[numthreads(1, 1, 1)]
+void unused_entry_point() {
+ return;
+}
+
+void a() {
+ int a_1 = 0;
+ do {
+ return;
+ } while (false);
+}
diff --git a/test/tint/switch/switch_only_default.wgsl.expected.glsl b/test/tint/switch/switch_only_default.wgsl.expected.glsl
new file mode 100644
index 0000000..6c18cd1
--- /dev/null
+++ b/test/tint/switch/switch_only_default.wgsl.expected.glsl
@@ -0,0 +1,16 @@
+#version 310 es
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void unused_entry_point() {
+ return;
+}
+void a() {
+ int a_1 = 0;
+ switch(a_1) {
+ default: {
+ return;
+ break;
+ }
+ }
+}
+
diff --git a/test/tint/switch/switch_only_default.wgsl.expected.ir.msl b/test/tint/switch/switch_only_default.wgsl.expected.ir.msl
new file mode 100644
index 0000000..c6fd336
--- /dev/null
+++ b/test/tint/switch/switch_only_default.wgsl.expected.ir.msl
@@ -0,0 +1,13 @@
+#include <metal_stdlib>
+using namespace metal;
+
+void a() {
+ int a = 0;
+ switch(a) {
+ default:
+ {
+ return;
+ }
+ }
+ /* unreachable */
+}
diff --git a/test/tint/switch/switch_only_default.wgsl.expected.msl b/test/tint/switch/switch_only_default.wgsl.expected.msl
new file mode 100644
index 0000000..9cce129
--- /dev/null
+++ b/test/tint/switch/switch_only_default.wgsl.expected.msl
@@ -0,0 +1,13 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void a() {
+ int a_1 = 0;
+ switch(a_1) {
+ default: {
+ return;
+ break;
+ }
+ }
+}
+
diff --git a/test/tint/switch/switch_only_default.wgsl.expected.spvasm b/test/tint/switch/switch_only_default.wgsl.expected.spvasm
new file mode 100644
index 0000000..6da1f12
--- /dev/null
+++ b/test/tint/switch/switch_only_default.wgsl.expected.spvasm
@@ -0,0 +1,40 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 19
+; Schema: 0
+ OpCapability Shader
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint GLCompute %unused_entry_point "unused_entry_point"
+ OpExecutionMode %unused_entry_point LocalSize 1 1 1
+ OpName %unused_entry_point "unused_entry_point"
+ OpName %a "a"
+ OpName %tint_return_flag "tint_return_flag"
+ OpName %a_1 "a_1"
+ %void = OpTypeVoid
+ %1 = OpTypeFunction %void
+ %bool = OpTypeBool
+%_ptr_Function_bool = OpTypePointer Function %bool
+ %10 = OpConstantNull %bool
+ %int = OpTypeInt 32 1
+ %12 = OpConstantNull %int
+%_ptr_Function_int = OpTypePointer Function %int
+ %true = OpConstantTrue %bool
+%unused_entry_point = OpFunction %void None %1
+ %4 = OpLabel
+ OpReturn
+ OpFunctionEnd
+ %a = OpFunction %void None %1
+ %6 = OpLabel
+%tint_return_flag = OpVariable %_ptr_Function_bool Function %10
+ %a_1 = OpVariable %_ptr_Function_int Function %12
+ OpStore %a_1 %12
+ %16 = OpLoad %int %a_1
+ OpSelectionMerge %15 None
+ OpSwitch %16 %17
+ %17 = OpLabel
+ OpStore %tint_return_flag %true
+ OpBranch %15
+ %15 = OpLabel
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/switch/switch_only_default.wgsl.expected.wgsl b/test/tint/switch/switch_only_default.wgsl.expected.wgsl
new file mode 100644
index 0000000..4291fb3
--- /dev/null
+++ b/test/tint/switch/switch_only_default.wgsl.expected.wgsl
@@ -0,0 +1,8 @@
+fn a() {
+ var a = 0;
+ switch(a) {
+ default: {
+ return;
+ }
+ }
+}