Beispiel #1
0
        public void StreamWithOffset()
        {
            var resolver = new StreamOffsetResolver();
            var options  = ScriptOptions.Default.WithSourceResolver(resolver);
            var script   = CSharpScript.Create(@"#load ""a.csx""", options);

            ScriptingTestHelpers.EvaluateScriptWithOutput(script, "Hello World!");
        }
Beispiel #2
0
        public void ReturnInLoadedFileTrailingVoidExpression()
        {
            var resolver = TestSourceReferenceResolver.Create(
                KeyValuePair.Create("a.csx", @"
if (false)
{
    return 1;
}
System.Console.WriteLine(42)"));
            var options = ScriptOptions.Default.WithSourceResolver(resolver);

            var script = CSharpScript.Create("#load \"a.csx\"", options);
            var result = ScriptingTestHelpers.EvaluateScriptWithOutput(script, "42");

            Assert.Null(result);

            script = CSharpScript.Create(@"
#load ""a.csx""
2", options);
            result = ScriptingTestHelpers.EvaluateScriptWithOutput(script, "42");
            Assert.Equal(2, result);
        }
Beispiel #3
0
        public async Task ReturnInNestedScopeWithTrailingVoidExpressionAsInt()
        {
            var script = CSharpScript.Create <int>(@"
bool condition = false;
if (condition)
{
    return 1;
}
System.Console.WriteLine();");
            var result = await script.EvaluateAsync();

            Assert.Equal(0, result);

            script = CSharpScript.Create <int>(@"
bool condition = false;
if (condition)
{
    return 1;
}
System.Console.WriteLine()");

            Assert.Equal(0, ScriptingTestHelpers.EvaluateScriptWithOutput(script, ""));
        }
Beispiel #4
0
 public void NoReturn()
 {
     Assert.Null(ScriptingTestHelpers.EvaluateScriptWithOutput(
                     CSharpScript.Create("System.Console.WriteLine();"), ""));
 }