本文整理汇总了C#中ProtoScript.Runners.ProtoScriptTestRunner.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# ProtoScript.Runners.ProtoScriptTestRunner.Execute方法的具体用法?C# ProtoScript.Runners.ProtoScriptTestRunner.Execute怎么用?C# ProtoScript.Runners.ProtoScriptTestRunner.Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProtoScript.Runners.ProtoScriptTestRunner
的用法示例。
在下文中一共展示了ProtoScript.Runners.ProtoScriptTestRunner.Execute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AccessGlobalVariableInsideFunction
public void AccessGlobalVariableInsideFunction()
{
string code = @"
arr = { 1, 2, 3 };
factor = 10;
def foo : int[]()
{
f = factor;
[Imperative]
{
ix = 0;
for(i in arr)
{
arr[ix] = arr[ix] * factor * f;
ix = ix + 1;
}
}
return = arr;
}
w = foo();
w0 = w[0];
w1 = w[1];
w2 = w[2];
";
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
ExecutionMirror mirror = fsr.Execute(code, core);
Assert.IsTrue((Int64)mirror.GetValue("w0").Payload == 100);
Assert.IsTrue((Int64)mirror.GetValue("w1").Payload == 200);
Assert.IsTrue((Int64)mirror.GetValue("w2").Payload == 300);
}
示例2: EmbeddedTest001
public void EmbeddedTest001()
{
String code =
@"x;[Associative]
{
x = 0;
[Imperative]
{
x = x + 5;
}
}
";
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
ExecutionMirror mirror = fsr.Execute(code, core, out compileState);
Obj o = mirror.GetValue("x");
Assert.IsTrue((Int64)o.Payload == 5);
}
[Test]
public void EmbeddedTest002()
{
String code =
@"
示例3:
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
fsr.Execute(
@"
[Associative]
{
a = [Imperative]
{
示例4: ExecuteAndVerify
protected int ExecuteAndVerify(String code, ValidationData[] data, Dictionary<string, Object> context, out int nErrors)
{
ProtoCore.Core core = Setup();
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
ExecutionMirror mirror = fsr.Execute(code, core, context);
int nWarnings = core.RuntimeStatus.WarningCount;
nErrors = core.BuildStatus.ErrorCount;
if (data == null)
{
core.Cleanup();
return nWarnings + nErrors;
}
TestFrameWork thisTest = new TestFrameWork();
foreach (var item in data)
{
if (item.ExpectedValue == null)
{
object nullOb = null;
TestFrameWork.Verify(mirror, item.ValueName, nullOb, item.BlockIndex);
}
else
{
TestFrameWork.Verify(mirror, item.ValueName, item.ExpectedValue, item.BlockIndex);
}
}
core.Cleanup();
return nWarnings + nErrors;
}
示例5: ExternCallTest
public void ExternCallTest()
{
//String code =
/*@"external (""ffi_library"") def sum_all : double (arr : double[], numElems : int);
def sum_all_2 : double (arr : double[], numElems : int)
{ return = 42;
}
arr = {1.0, 2, 3, 4, 5, 6, 7, 8, 9, 10};
sum_1_to_10 = sum_all_2(arr, 10);";
*/
String code =
@"external (""ffi_library"") def sum_all : double (arr : double[], numElems : int);
arr = {1.0, 2, 3, 4, 5, 6, 7, 8, 9, 10};
sum_1_to_10 = sum_all(arr, 10);";
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
ExecutionMirror mirror = fsr.Execute(code, core);
Obj o = mirror.GetValue("sum_1_to_10");
Assert.IsTrue((Int64)o.Payload == 55);
}
示例6: GetUpcastChainTest
public void GetUpcastChainTest()
{
String code =
@"class A {}
class B extends A {}
class C extends B {}
";
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
ExecutionMirror mirror = fsr.Execute(code, core);
int idA = core.ClassTable.IndexOf("A");
int idB = core.ClassTable.IndexOf("B");
int idC = core.ClassTable.IndexOf("C");
ClassNode cnA = core.ClassTable.ClassNodes[idA];
ClassNode cnB = core.ClassTable.ClassNodes[idB];
ClassNode cnC = core.ClassTable.ClassNodes[idC];
List<int> idsA = ClassUtils.GetClassUpcastChain(cnA, core);
List<int> idsB = ClassUtils.GetClassUpcastChain(cnB, core);
List<int> idsC = ClassUtils.GetClassUpcastChain(cnC, core);
Assert.IsTrue(idsA.Count == 2);
Assert.IsTrue(idsA.Contains(idA));
Assert.IsTrue(idsB.Count == 3);
Assert.IsTrue(idsB.Contains(idA));
Assert.IsTrue(idsB.Contains(idB));
Assert.IsTrue(idsC.Count == 4);
Assert.IsTrue(idsC.Contains(idA));
示例7: StackValueDiffTestProperty01
public void StackValueDiffTestProperty01()
{
String code =
@"
class A
{
x : var;
constructor A()
{
x = 20;
}
}
[Imperative]
{
a = A.A();
b = 1.0;
}
";
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
ProtoCore.RuntimeCore runtimeCore = null;
ExecutionMirror mirror = fsr.Execute(code, core, out runtimeCore);
StackValue svA = mirror.GetRawFirstValue("a");
StackValue svB = mirror.GetRawFirstValue("b");
Assert.IsTrue(svA.metaData.type != svB.metaData.type);
}
示例8: SimpleCtorResolution01
public void SimpleCtorResolution01()
{
String code =
@"
class f
{
fx : var;
fy : var;
constructor f()
{
fx = 123;
fy = 345;
}
}
// Construct class 'f'
cf = f.f();
x = cf.fx;
y = cf.fy;
";
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
ExecutionMirror mirror = fsr.Execute(code, core, out compileState);
Assert.IsTrue((Int64)mirror.GetValue("x").Payload == 123);
Assert.IsTrue((Int64)mirror.GetValue("y").Payload == 345);
}
示例9: TestClassUsageInImpeartive
public void TestClassUsageInImpeartive()
{
ProtoCore.Core core = new ProtoCore.Core(new ProtoCore.Options());
core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
ExecutionMirror mirror = fsr.Execute(
@"
class foo
{
m : var;
constructor Create(a1 : int)
{
m = a1;
}
}
x;y;
[Imperative]
{
p = foo.Create(16);
x = p.m;
p.m = 32;
y = p.m;
}
"
, core, out compileState);
Assert.IsTrue((Int64)mirror.GetValue("x", 0).Payload == 16);
Assert.IsTrue((Int64)mirror.GetValue("y", 0).Payload == 32);
}
示例10:
ExecutionMirror mirror = fsr.Execute(
@"
a;
[Associative]
{
a =
{
示例11: ModifierStackWithArray
public void ModifierStackWithArray()
{
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
ExecutionMirror mirror = fsr.Execute(
@"
a;
[email protected];
[email protected];
[Associative]
{
a =
{
{3, 2, 1} => [email protected];
1 => [email protected];
}
}
", core, out compileState);
Obj o = mirror.GetValue("[email protected]");
List<Obj> os = mirror.GetArrayElements(o);
Assert.IsTrue(os.Count == 3);
Assert.IsTrue((Int64)os[0].Payload == 3);
Assert.IsTrue((Int64)os[1].Payload == 2);
Assert.IsTrue((Int64)os[2].Payload == 1);
Assert.IsTrue((Int64)mirror.GetValue("[email protected]", 0).Payload == 1);
}
示例12: ClassTest
public void ClassTest()
{
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
fsr.Execute(
@"
[Associative]
{
class Point
{
mx : var;
my : var;
mz : var;
constructor Point(xx : double, yy : double, zz : double)
{
mz = xx;
my = yy;
mx = zz;
}
}
point = Point.Point(10,10,10);
}
", core, out compileState);
//Object o = mirror.GetValue("point.mx");
//Assert.IsTrue((long)o == 10);
}
示例13: TestScript
public void TestScript(string scriptCode)
{
ProtoCore.Core core = new ProtoCore.Core(new ProtoCore.Options());
core.Executives.Add(ProtoCore.Language.kAssociative, new ProtoAssociative.Executive(core));
core.Executives.Add(ProtoCore.Language.kImperative, new ProtoImperative.Executive(core));
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
fsr.Execute(scriptCode, core);
}
示例14:
";
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
ExecutionMirror mirror = fsr.Execute(code, core);
Obj o = mirror.GetValue("x");
Assert.IsTrue((Int64)o.Payload == 6);
}
[Test]
示例15: RedefineWithFunctions02
ProtoScript.Runners.ProtoScriptTestRunner fsr = new ProtoScript.Runners.ProtoScriptTestRunner();
ExecutionMirror mirror = fsr.Execute(code, core);
Assert.IsTrue((Int64)mirror.GetValue("x").Payload == 1001);
}
[Test]
[Category("ToFixYuKe")]
public void RedefineWithFunctions02()