Files
swift-mirror/validation-test/stdlib/NumericDiagnostics.swift.gyb
Flash Sheridan c11eb40008 Iterate over more documented operators, now that the documentation has improved; now 3460 tests.
Replace hard-coded lists of real-number types, and of arithmetic and logical operators I’m testing, with lists added to SwiftIntTypes.py, which becomes a bit of a misnomer.  
Separate them into ones which only work on integer types, and those which also allow reals.
Do a double loop, over just the integers and then the reals as well.
Change the run line to allow importing StdlibUnittest with help from Dmitri, which I won't actually need until I do result type checking.

Approved by Dmitri.

Swift SVN r24029
2014-12-19 04:20:03 +00:00

35 lines
1.4 KiB
Plaintext

// RUN: rm -rf %t && mkdir -p %t && %S/../../utils/gyb %s -o %t/main.swift
// RUN: %S/../../utils/line-directive %t/main.swift -- %target-build-swift -parse -Xfrontend -verify %t/main.swift
% from SwiftIntTypes import all_numeric_type_names, all_integer_type_names, \
% all_integer_binary_operator_names, all_integer_or_real_binary_operator_names, \
% all_arithmetic_comparison_operator_names, all_integer_assignment_operator_names, \
% all_integer_or_real_assignment_operator_names
% int_ops = all_integer_binary_operator_names() + all_integer_assignment_operator_names()
% arith_ops = all_integer_or_real_binary_operator_names() + \
% all_arithmetic_comparison_operator_names() + all_integer_or_real_assignment_operator_names()
//TODO: Better error regex, verify the type of the result, Float80 for i386 & x86_64
func testIteratedOperations() {
% for typesToTest, operatorsToTest in zip([all_integer_type_names(), all_numeric_type_names()], \
% [int_ops, arith_ops]):
% operatorsToTest = [x for x in operatorsToTest if not '+' in x and not '-' in x]
%# TODO: rm when rdar://18695154 is fixed.
// typesToTest: ${typesToTest}, operatorsToTest: ${operatorsToTest}
% for T1 in typesToTest:
% for T2 in typesToTest:
% for op in operatorsToTest:
if true {
var x1_${T1}: ${T1} = 0
var x2_${T2}: ${T2} = 0
x1_${T1} ${op} x2_${T2} ${ "// expected-error{{ }}" if T1 != T2 else "" }
}
%end
%end
%end
%end
}