public void testMoreReordering() { var strict = new StrictInterpreter(); // The non-strict interpreter moves around arguments such that they will continue to work. Assert.Equal("[[] d c b a 6]", Run("[[2 a negate 3 b c 5 + d +]]")); Assert.Equal("[[2 negate 3 5 + + a b c d]]", reorderInterpreter.Reorder("[[2 a negate 3 b c 5 + d +]]".ToStack()).ToRepr()); Assert.Equal("[[] d c b a 6]", strict.Run("[[2 negate 3 5 + + a b c d]]".ToStack()).ToRepr()); // Can't run the original with the strict interpreter. Assert.Throws <InvalidCastException>(() => strict.Run("[[2 a negate 3 b c 5 + d +]]".ToStack())); }
public void testMoreReordering4() { var strict = new StrictInterpreter(); // The non-strict interpreter moves around arguments such that they will continue to work. Assert.Equal("[[] d c b a 3]", Run("[[2 a negate 3 pop b c 5 + d + +]]")); Assert.Equal("[[3 pop 2 negate 5 + a b c d]]", Reorder("[[2 a negate 3 pop b c 5 + d + +]]")); // The same output is produced. Assert.Equal("[[] d c b a 3]", strict.Run("[[2 negate 5 + a 3 pop b c d]]".ToStack()).ToRepr()); // Can't run the original with the strict interpreter. Assert.Throws <InvalidCastException>(() => strict.Run("[[2 a negate 3 pop b c 5 + d + +]]".ToStack())); Assert.Throws <InvalidOperationException>(() => strict.Run("[[2 +]]".ToStack())); Assert.Throws <InvalidOperationException>(() => strict.Run("[[+]]".ToStack())); }