<commit_before>//===--- Interval.swift ---------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
// RUN: %target-run-simple-swift
//
// XFAIL: interpret
// XFAIL: linux

import StdlibUnittest

var IntervalTestSuite = TestSuite("Interval")

func expectType<T>(T.Type, x: T) {
}

IntervalTestSuite.test("Ambiguity") {
  // Ensure type deduction still works as expected; these will fail to
  // compile if it's broken
  let pieToPie = -3.1415927..<3.1415927
  expectType(HalfOpenInterval<Double>.self, pieToPie)
  
  let pieThruPie = -3.1415927...3.1415927
  expectType(ClosedInterval<Double>.self, pieThruPie)
  
  let zeroToOne = 0..<1
  expectType(Range<Int>.self, zeroToOne)
  
  let zeroThruOne = 0...1
  // If/when we get a separate ClosedRange representation, this test
  // will have to change.
  expectType(Range<Int>.self, zeroThruOne)
}

IntervalTestSuite.test("PatternMatching") {

  let pie = 3.1415927

  let expectations : [(Double, halfOpen: Bool, closed: Bool)] = [
    (-2 * pie, false, false),
    (-pie, true, true),
    (0, true, true),
    (pie, false, true),
    (2 * pie, false, false)
  ]

  for (x, halfOpenExpected, closedExpected) in expectations {
    var halfOpen: Bool
    switch x {
    case -3.1415927..<3.1415927:
      halfOpen = true
    default:
      halfOpen = false
    }

    var closed: Bool<commit_msg>stdlib/tests: remove duplicate expectType() function<commit_after>//===--- Interval.swift ---------------------------------------------------===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
// RUN: %target-run-simple-swift
//
// XFAIL: interpret
// XFAIL: linux

import StdlibUnittest

var IntervalTestSuite = TestSuite("Interval")

IntervalTestSuite.test("Ambiguity") {
  // Ensure type deduction still works as expected; these will fail to
  // compile if it's broken
  var pieToPie = -3.1415927..<3.1415927
  expectType(HalfOpenInterval<Double>.self, &pieToPie)

  var pieThruPie = -3.1415927...3.1415927
  expectType(ClosedInterval<Double>.self, &pieThruPie)

  var zeroToOne = 0..<1
  expectType(Range<Int>.self, &zeroToOne)

  var zeroThruOne = 0...1
  // If/when we get a separate ClosedRange representation, this test
  // will have to change.
  expectType(Range<Int>.self, &zeroThruOne)
}

IntervalTestSuite.test("PatternMatching") {

  let pie = 3.1415927

  let expectations : [(Double, halfOpen: Bool, closed: Bool)] = [
    (-2 * pie, false, false),
    (-pie, true, true),
    (0, true, true),
    (pie, false, true),
    (2 * pie, false, false)
  ]

  for (x, halfOpenExpected, closedExpected) in expectations {
    var halfOpen: Bool
    switch x {
    case -3.1415927..<3.1415927:
      halfOpen = true
    default:
      halfOpen = false
    }

    var closed: Bool
{'fraction_non_alphanumeric': 0.1944835350408106, 'fraction_numerical': 0.04109203490008444, 'mean_word_length': 2.417307692307692, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 12, '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': '6247633', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1078, 'n_words': 319}