public void GotoDefault_NoSingleton() { var g1 = CSharpStatement.GotoDefault(); var g2 = CSharpStatement.GotoDefault(); Assert.AreNotSame(g1, g2); }
public void GotoDefault_Visitor() { var g = CSharpStatement.GotoDefault(); var v = new V(); Assert.AreSame(g, v.Visit(g)); Assert.AreEqual(g.Kind, v.VisitedKind); }
public void GotoDefault_Properties() { var g = CSharpStatement.GotoDefault(); Assert.AreEqual(typeof(void), g.Type); Assert.AreEqual(CSharpExpressionType.Goto, g.CSharpNodeType); Assert.AreEqual(CSharpGotoKind.GotoDefault, g.Kind); Assert.IsFalse(g.CanReduce); AssertEx.Throws <InvalidOperationException>(() => g.Reduce()); }
public void Switch_Compile_NestedSwitch1() { AssertCompile <int>((log, v) => SwitchLogValue(log, v, log("XD"), CSharpStatement.SwitchCase( new[] { 1 }, CSharpStatement.Switch( Expression.Constant(3), Expression.Label(), log("D"), CSharpStatement.SwitchCase(new[] { 3 }, log("A"), CSharpStatement.GotoDefault(), log("X")) ) ), CSharpStatement.SwitchCase(new[] { 2 }, log("XC")), CSharpStatement.SwitchCase(new[] { 3 }, log("B"), CSharpStatement.GotoDefault()) ), new Asserts <int> { { 0, "E", "XD" }, { 1, "E", "A", "D" }, { 2, "E", "XC" }, { 3, "E", "B", "XD" }, } ); }
public void Switch_Compile_GotoDefault_Error() { var res = CSharpStatement.Switch(Expression.Constant(1), Expression.Label(), CSharpStatement.SwitchCase(new[] { 1 }, CSharpStatement.GotoDefault())); AssertEx.Throws <InvalidOperationException>(() => res.Reduce(), ex => ex.Message.Contains("goto default")); }
public void Switch_Compile_GotoDefault_Null() { AssertCompile <int?>((log, v) => SwitchLogValue(log, v, log("D"), CSharpStatement.SwitchCase(new[] { 1 }, log("A")), CSharpStatement.SwitchCase(new[] { 2 }, log("B")), CSharpStatement.SwitchCase(new[] { default(int?) }, log("N"), CSharpStatement.GotoDefault(), log("X")) ), new Asserts <int?> { { 0, "E", "D" }, { 1, "E", "A" }, { 2, "E", "B" }, { 3, "E", "D" }, { null, "E", "N", "D" } } ); }