public void compares_different_blocks() { var o1 = UnifiedBlock.Create( new UnifiedExpression[] { UnifiedBinaryExpression.Create( UnifiedVariableIdentifier.Create("n"), UnifiedBinaryOperator.Create( "=", UnifiedBinaryOperatorKind.Assign), UnifiedInt32Literal.Create(1)), UnifiedReturn.Create( UnifiedInt32Literal.Create(2)), }); var o2 = UnifiedBlock.Create( new UnifiedExpression[] { UnifiedBinaryExpression.Create( UnifiedVariableIdentifier.Create("n"), UnifiedBinaryOperator.Create( "=", UnifiedBinaryOperatorKind.Assign), UnifiedInt32Literal.Create(2)), UnifiedReturn.Create( UnifiedInt32Literal.Create(2)), }); Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.False); }
public void compares_string_null() { var o1 = "abc"; object o2 = null; Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.False); }
public void compares_same_strings() { var o1 = "abc"; var o2 = o1; Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.True); }
public void compares_null_string() { object o1 = null; var o2 = "abc"; Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.False); }
public void compares_different_types() { var o1 = "abc"; var o2 = new object(); Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.False); }
public void compares_null_null() { object o1 = null; object o2 = null; Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.True); }
public void compares_equal_ints() { var o1 = 0; var o2 = 0; Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.True); }
public void compares_different_strings() { var o1 = "abc"; var o2 = "abcd"; Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.False); }
public void compares_different_ints() { var o1 = 1; var o2 = -1; Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.False); }
public void compares_same_stringLists() { var o1 = new List <string> { "1", "2" }; var o2 = o1; Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.True); }
public void compares_same_expressions_containing_null() { var o2 = UnifiedBinaryExpression.Create( UnifiedVariableIdentifier.Create("n"), null, UnifiedInt32Literal.Create(1)); var o1 = o2; Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.True); }
public void compares_same_intLists() { var o1 = new List <int> { 1, 2 }; var o2 = o1; Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.True); }
public void compares_different_intLists() { var o1 = new List <int> { 1, 2 }; var o2 = new List <int> { 1, 3 }; Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.False); }
public void compares_different_stringLists() { var o1 = new List <string> { "1", "2" }; var o2 = new List <string> { "1", "3" }; Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.False); }
public void compares_same_expressions() { var o2 = UnifiedBinaryExpression.Create( UnifiedVariableIdentifier.Create("n"), UnifiedBinaryOperator.Create( "-", UnifiedBinaryOperatorKind.Subtract), UnifiedInt32Literal.Create(1)); var o1 = o2; Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.True); }
public void compares_different_expressions_containing_null() { var o1 = UnifiedBinaryExpression.Create( UnifiedVariableIdentifier.Create("n"), null, UnifiedInt32Literal.Create(1)); var o2 = UnifiedBinaryExpression.Create( UnifiedVariableIdentifier.Create("n"), UnifiedBinaryOperator.Create( null, UnifiedBinaryOperatorKind.Add), UnifiedInt32Literal.Create(1)); Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.False); }
public void compares_different_calls() { var o1 = UnifiedCall.Create( UnifiedVariableIdentifier.Create("f"), UnifiedSet <UnifiedArgument> .Create( UnifiedArgument.Create( UnifiedVariableIdentifier.Create( "a"), null, null), UnifiedArgument.Create( UnifiedBinaryExpression.Create( UnifiedVariableIdentifier. Create("n"), UnifiedBinaryOperator.Create ( "-", UnifiedBinaryOperatorKind .Add), UnifiedInt32Literal.Create( 1) ), null, null))); var o2 = UnifiedCall.Create( UnifiedVariableIdentifier.Create("f"), UnifiedSet <UnifiedArgument> .Create( UnifiedArgument.Create( UnifiedVariableIdentifier.Create( "a"), null, null), UnifiedArgument.Create( UnifiedBinaryExpression.Create( UnifiedVariableIdentifier. Create("n2"), UnifiedBinaryOperator.Create ( "-", UnifiedBinaryOperatorKind .Add), UnifiedInt32Literal.Create( 1)), null, null))); Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.False); }
public void compares_intListLists_subintListLists() { var o1 = new List <List <int> > { new List <int> { 1, 2 }, new List <int> { 1, 2, 4 } }; var o2 = new List <List <int> > { new List <int> { 1, 2 }, new List <int> { 1, 2 } }; Assert.That( StructuralEqualityComparer.StructuralEquals(o1, o2), Is.False); }
bool IEqualityComparer <object> .Equals(object x, object y) { var result = StructuralEqualityComparer.StructuralEquals(x, y); if (result) { return(true); } var x2 = x as UnifiedElement; if (x2 != null) { File.WriteAllText( FixtureUtil.GetOutputPath("model1.txt"), x2.ToString()); } var y2 = y as UnifiedElement; if (y2 != null) { File.WriteAllText( FixtureUtil.GetOutputPath("model2.txt"), y2.ToString()); } return(false); }
/// <summary> /// 指定しオブジェクトのプロパティを再帰的に比較してオブジェクト同士の等価性を判断します. /// </summary> /// <param name="element"> </param> /// <param name="that"> </param> /// <returns> </returns> public static bool StructuralEquals( this UnifiedElement element, UnifiedElement that) { return(StructuralEqualityComparer.StructuralEquals(element, that)); }