From cf8e32dc53dd318b210f46c954d50e08b1d52030 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 3 Sep 2020 20:57:24 +0000 Subject: [PATCH] add a test case for an invalid optimizatio A recent optimization was overly aggressive and resulted in a miscompile in FoundationNetworking. Add a test case. --- .../test-foundation-networking-fetch.swift | 6 ++++++ .../test-foundation-networking-fetch.txt | 8 ++++++++ 2 files changed, 14 insertions(+) create mode 100644 test-foundation-package/test-foundation-networking-fetch.swift create mode 100644 test-foundation-package/test-foundation-networking-fetch.txt diff --git a/test-foundation-package/test-foundation-networking-fetch.swift b/test-foundation-package/test-foundation-networking-fetch.swift new file mode 100644 index 0000000..741320a --- /dev/null +++ b/test-foundation-package/test-foundation-networking-fetch.swift @@ -0,0 +1,6 @@ +import Foundation +import FoundationNetworking + +let url = URL(string: "http://swift.org")! +let data = try! Data(contentsOf: url) +print(data.underestimatedCount) diff --git a/test-foundation-package/test-foundation-networking-fetch.txt b/test-foundation-package/test-foundation-networking-fetch.txt new file mode 100644 index 0000000..4425c5f --- /dev/null +++ b/test-foundation-package/test-foundation-networking-fetch.txt @@ -0,0 +1,8 @@ +REQUIRES: platform=Linux + +RUN: rm -rf %t +RUN: mkdir -p %t +RUN: %{swiftc} -o %t/test-foundation-networking-fetch %S/test-foundation-networking-fetch.swift +RUN: %t/test-foundation-networking-fetch | %{FileCheck} %s + +CHECK: {{[0-9]+}}