summaryrefslogtreecommitdiff
path: root/Source/UnitTests
diff options
context:
space:
mode:
authorGravatar Dan Liew <daniel.liew@imperial.ac.uk>2015-01-29 03:47:05 +0000
committerGravatar Dan Liew <daniel.liew@imperial.ac.uk>2015-01-29 03:47:05 +0000
commitcef89809053b0679019491a227ed03c98be44854 (patch)
tree12cb272e3b1f0a56f0bdd7bcee111d2be2d863a9 /Source/UnitTests
parent9ecdcd65b9173736a191662072865ec0bb075c04 (diff)
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.
Diffstat (limited to 'Source/UnitTests')
-rw-r--r--Source/UnitTests/CoreTests/ExprImmutability.cs7
1 files changed, 7 insertions, 0 deletions
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);
+ }
}
}