From cef89809053b0679019491a227ed03c98be44854 Mon Sep 17 00:00:00 2001 From: Dan Liew Date: Thu, 29 Jan 2015 03:47:05 +0000 Subject: Protect the NAryExpr.Fun field when the NAryExpr is immutable. Add a unit test for this. We need to protect the Args field too but that is going to be much harder to enforce. --- Source/UnitTests/CoreTests/ExprImmutability.cs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Source/UnitTests/CoreTests') diff --git a/Source/UnitTests/CoreTests/ExprImmutability.cs b/Source/UnitTests/CoreTests/ExprImmutability.cs index e13feca7..aff0acea 100644 --- a/Source/UnitTests/CoreTests/ExprImmutability.cs +++ b/Source/UnitTests/CoreTests/ExprImmutability.cs @@ -96,6 +96,13 @@ namespace CoreTests var e = new OldExpr(Token.NoToken, Expr.True, /*immutable=*/ true); e.Expr = Expr.False; } + + [Test(), ExpectedException(typeof(InvalidOperationException))] + public void ProtectedNAryFunc() + { + var e = GetUnTypedImmutableNAry(); + e.Fun = new BinaryOperator(Token.NoToken, BinaryOperator.Opcode.Sub); + } } } -- cgit v1.2.3