<commit_before>// RUN: %target-build-swift -module-name a %s -o %t.out
// RUN: %target-run %t.out
// REQUIRES: executable_test

// XFAIL: linux

//
// This file contains reflection tests that depend on hash values.
// Don't add other tests here.
//

import StdlibUnittest

// Also import modules which are used by StdlibUnittest internally. This
// workaround is needed to link all required libraries in case we compile
// StdlibUnittest with -sil-serialize-all.
import SwiftPrivate
#if _runtime(_ObjC)
import ObjectiveC
#endif

var Reflection = TestSuite("Reflection")

Reflection.test("Dictionary/Empty") {
  let dict = [Int : Int]()

  var output = ""
  dump(dict, &output)

  var expected = "- 0 key/value pairs\n"

  expectEqual(expected, output)
}

Reflection.test("Dictionary") {
  let dict = [ "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5 ]

  var output = ""
  dump(dict, &output)

#if arch(i386) || arch(arm)
  var expected = ""
  expected += "▿ 5 key/value pairs\n"
  expected += "  ▿ [0]: (2 elements)\n"
  expected += "    - .0: Four\n"
  expected += "    - .1: 4\n"
  expected += "  ▿ [1]: (2 elements)\n"
  expected += "    - .0: One\n"
  expected += "    - .1: 1\n"
  expected += "  ▿ [2]: (2 elements)\n"
  expected += "    - .0: Two\n"
  expected += "    - .1: 2\n"
  expected += "  ▿ [3]: (2 elements)\n"
  expected += "    - .0: Five\n"
  expected += "    - .1: 5\n"
  expected += "  ▿ [4]: (2 elements)\n"
  expected += "    - .0: Three\n"
  expected += "    - .1: 3\n"
#elseif arch(x86_64) || arch(arm64)
  var expected = ""
  expected += "▿ 5 key/value pairs\n"
  expected += "  ▿ [0]: (2 elements)\n"
  expected += "    - .0: Five\n"
  expected += "    - .1: 5\n"
  expected += "  ▿ [1]: (2 elements)\n"
  expected += "    - .0: Two\n"
  expected += "    - .1: 2\n"
  expected += "  ▿ [2]: (2 elements)\n"
  expected += "    - .0: One\n"
  expected += "    - .1: 1\n"
  expected += "  ▿ [3]: (2 elements)\n"
  expected += "    - .0: Three\n"
  expected += "    - .1: 3\n"
  expected += "  ▿ [4]: (2 elements)\n"
  expected += "    - .0: Four\n"
  expected += "    - .1: 4\n"
#else
  fatalError("unimplemented")
#endif

  expectEqual(expected, output)
}

Reflection.test("Set") {
  let s = Set(1...5)

  var output = ""
  dump(s, &output)

#if arch(i386) || arch(arm)
  var expected = ""<commit_msg>[StdLib] Extend ReflectionHashing test to pass on Linux<commit_after>// RUN: %target-build-swift -module-name a %s -o %t.out
// RUN: %target-run %t.out
// REQUIRES: executable_test

//
// This file contains reflection tests that depend on hash values.
// Don't add other tests here.
//

import StdlibUnittest

// Also import modules which are used by StdlibUnittest internally. This
// workaround is needed to link all required libraries in case we compile
// StdlibUnittest with -sil-serialize-all.
import SwiftPrivate
#if _runtime(_ObjC)
import ObjectiveC
#endif

var Reflection = TestSuite("Reflection")

Reflection.test("Dictionary/Empty") {
  let dict = [Int : Int]()

  var output = ""
  dump(dict, &output)

  var expected = "- 0 key/value pairs\n"

  expectEqual(expected, output)
}

Reflection.test("Dictionary") {
  let dict = [ "One": 1, "Two": 2, "Three": 3, "Four": 4, "Five": 5 ]

  var output = ""
  dump(dict, &output)

#if _runtime(_ObjC) && (arch(i386) || arch(arm))
  var expected = ""
  expected += "▿ 5 key/value pairs\n"
  expected += "  ▿ [0]: (2 elements)\n"
  expected += "    - .0: Four\n"
  expected += "    - .1: 4\n"
  expected += "  ▿ [1]: (2 elements)\n"
  expected += "    - .0: One\n"
  expected += "    - .1: 1\n"
  expected += "  ▿ [2]: (2 elements)\n"
  expected += "    - .0: Two\n"
  expected += "    - .1: 2\n"
  expected += "  ▿ [3]: (2 elements)\n"
  expected += "    - .0: Five\n"
  expected += "    - .1: 5\n"
  expected += "  ▿ [4]: (2 elements)\n"
  expected += "    - .0: Three\n"
  expected += "    - .1: 3\n"
#elseif _runtime(_ObjC) && (arch(x86_64) || arch(arm64))
  var expected = ""
  expected += "▿ 5 key/value pairs\n"
  expected += "  ▿ [0]: (2 elements)\n"
  expected += "    - .0: Five\n"
  expected += "    - .1: 5\n"
  expected += "  ▿ [1]: (2 elements)\n"
  expected += "    - .0: Two\n"
  expected += "    - .1: 2\n"
  expected += "  ▿ [2]: (2 elements)\n"
  expected += "    - .0: One\n"
  expected += "    - .1: 1\n"
  expected += "  ▿ [3]: (2 elements)\n"
  expected += "    - .0: Three\n"
  expected += "    - .1: 3\n"
  expected += "  ▿ [4]: (2 elements)\n"
  expected += "    - .0: Four\n"
  expected += "    - .1: 4\n"
#elseif !_runtime(_ObjC) && arch(x86_64)
  var expected = ""
  expected += "▿ 5 key/value pairs\n"
  expected += "  ▿ [0]: (2 elements)\n"
  expected += "    - .0: One\n"
  expected += "    - .1: 1\n"
  expected += "  ▿ [1]: (2 elements)\n"
  expected += "    - .0: Five\n"
  expected += "    - .1: 5\n"
  expected += "  ▿ [2]: (2 elements)\n"
  expected += "    - .0: Two\n"
  expected += "    - .1: 2\n"
  expected += "  ▿ [3]: (2 elements)\n"
  expected += "    - .0: Four\n"
  expected += "    - .1: 4\n"
  expected += "  ▿ [4]: (2 elements)\n"
  expected += "    - .0: Three\n"
  expected += "    - .1: 3\n"
#else
  fatalError("unimplemented")
#endif

  expectEqual(expected, output)
}

Reflection.test("Set") {
  let s = Set(1...5)

  var output = ""
  dump(s, &output)

#if arch(i386) || arch(arm)
  var expected = ""
{'fraction_non_alphanumeric': 0.20561797752808988, 'fraction_numerical': 0.03258426966292135, 'mean_word_length': 2.417146513115803, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3614377', 'n_tokens_mistral': 2195, 'n_tokens_neox': 2073, 'n_words': 568}