public override int lastIndexOf(ReadOnlySpan <T> span, T item) { if (item == null || !s_typeHasSpecialStrictEq || !ClassTagSet.specialStrictEquality.contains(item.AS_class.tag)) { for (int i = span.Length - 1; i >= 0; i--) { if (span[i] == item) { return(i); } } } else if (ASObject.AS_isNumeric(item)) { double itemVal = ASObject.AS_toNumber(item); for (int i = span.Length - 1; i >= 0; i--) { if (ASObject.AS_isNumeric(span[i]) && ASObject.AS_toNumber(span[i]) == itemVal) { return(i); } } } else if (item is ASString) { string itemVal = ASObject.AS_coerceString(item); for (int i = span.Length - 1; i >= 0; i--) { if (span[i] is ASString && ASObject.AS_coerceString(span[i]) == itemVal) { return(i); } } } else { for (int i = span.Length - 1; i >= 0; i--) { if (ASObject.AS_strictEq(span[i], item)) { return(i); } } } return(-1); }
/// <summary> /// Asserts that two instances of the <see cref="ASAny"/> type are equal, using value equality /// for primitive types and reference equality for object types. This considers NaNs to be equal /// to each other, and the +0 and -0 floating-point values to be not equal. /// </summary> /// <param name="expected">The expected <see cref="ASAny"/> instance.</param> /// <param name="actual">The actual instance to check against <see cref="expected"/>.</param> public static void valueIdentical(ASAny expected, ASAny actual) { if (ASObject.AS_isNumeric(expected.value) && ASObject.AS_isNumeric(actual.value)) { floatIdentical((double)expected, (double)actual); } else if (expected.value is ASString && actual.value is ASString) { Assert.Equal((string)expected, (string)actual); } else if (expected.value is ASBoolean && actual.value is ASBoolean) { Assert.Equal((bool)expected, (bool)actual); } else { identical(expected, actual); } }
public void convertFromNumberTest_array(double[] data) { runConvertArrayTest <double, int>(data, x => ASNumber.AS_toInt(x)); runConvertArrayTest <double, uint>(data, x => ASNumber.AS_toUint(x)); runConvertArrayTest <double, double>(data, x => x, AssertHelper.floatIdentical); runConvertArrayTest <double, bool>(data, x => ASNumber.AS_toBoolean(x)); runConvertArrayTest <double, string>(data, x => ASNumber.AS_convertString(x)); runConvertArrayTest <double, ASObject>(data, x => x, (expected, actual) => { Assert.True(ASObject.AS_isNumeric(actual)); AssertHelper.floatIdentical((double)expected, (double)actual); }); runConvertArrayTest <double, ASAny>(data, x => x, (expected, actual) => { Assert.True(ASObject.AS_isNumeric(actual.value)); AssertHelper.floatIdentical((double)expected, (double)actual); }); runConvertArrayTest(data, invalidConversion <double, GenericTypeConvertersTest_CA>); runConvertArrayTest(data, invalidConversion <double, GenericTypeConvertersTest_IA>); runConvertArrayTest(data, invalidConversion <double, GenericTypeConvertersTest_NonASType1>); }