本文整理汇总了C#中JSIL.Tests.ComparisonTest.RunJavascript方法的典型用法代码示例。如果您正苦于以下问题:C# ComparisonTest.RunJavascript方法的具体用法?C# ComparisonTest.RunJavascript怎么用?C# ComparisonTest.RunJavascript使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSIL.Tests.ComparisonTest
的用法示例。
在下文中一共展示了ComparisonTest.RunJavascript方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenericIgnoreTest
protected string GenericIgnoreTest(string fileName, string workingOutput, string jsErrorSubstring, string[] stubbedAssemblies = null)
{
long elapsed, temp;
string generatedJs = null, jsOutput = null;
using (var test = new ComparisonTest(EvaluatorPool, Portability.NormalizeDirectorySeparators(fileName), stubbedAssemblies)) {
var csOutput = test.RunCSharp(new string[0], out elapsed);
Assert.AreEqual(workingOutput, csOutput.Trim());
try {
jsOutput = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed, MakeConfiguration);
Assert.Fail("Expected javascript to throw an exception containing the string \"" + jsErrorSubstring + "\".");
} catch (JavaScriptEvaluatorException jse) {
bool foundMatch = false;
foreach (var exc in jse.Exceptions) {
if (exc.Message.Contains(jsErrorSubstring)) {
foundMatch = true;
break;
}
}
if (!foundMatch) {
Console.Error.WriteLine("// Was looking for a JS exception containing the string '{0}' but didn't find it.", jsErrorSubstring);
Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
if (jsOutput != null)
Console.Error.WriteLine("// JS output: \r\n{0}", jsOutput);
throw;
}
} catch {
Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
if (jsOutput != null)
Console.Error.WriteLine("// JS output: \r\n{0}", jsOutput);
throw;
}
}
return generatedJs;
}
示例2: GenericTest
protected string GenericTest(
string fileName, string csharpOutput,
string javascriptOutput, string[] stubbedAssemblies = null,
TypeInfoProvider typeInfo = null
)
{
long elapsed, temp;
string generatedJs = null;
using (var test = new ComparisonTest(EvaluatorPool, Portability.NormalizeDirectorySeparators(fileName), stubbedAssemblies, typeInfo)) {
var csOutput = test.RunCSharp(new string[0], out elapsed);
try {
var jsOutput = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed, MakeConfiguration);
Assert.AreEqual(Portability.NormalizeNewLines(csharpOutput), csOutput.Trim(), "Did not get expected output from C# test");
Assert.AreEqual(Portability.NormalizeNewLines(javascriptOutput), jsOutput.Trim(), "Did not get expected output from JavaScript test");
} catch {
Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
throw;
}
}
return generatedJs;
}
示例3: GenericTest
protected string GenericTest(string fileName, string csharpOutput, string javascriptOutput, Regex[] stubbedAssemblies = null)
{
long elapsed, temp;
string generatedJs;
using (var test = new ComparisonTest(fileName, stubbedAssemblies)) {
var csOutput = test.RunCSharp(new string[0], out elapsed);
var jsOutput = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed);
Assert.AreEqual(csharpOutput, csOutput.Trim(), "Did not get expected output from C# test");
Assert.AreEqual(javascriptOutput, jsOutput.Trim(), "Did not get expected output from JavaScript test");
}
return generatedJs;
}
示例4: GetJavascript
protected string GetJavascript(string fileName, string expectedText = null)
{
long elapsed, temp;
string generatedJs;
using (var test = new ComparisonTest(fileName)) {
var output = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed);
if (expectedText != null)
Assert.AreEqual(expectedText, output.Trim());
}
return generatedJs;
}
示例5: GenericIgnoreTest
protected string GenericIgnoreTest(string fileName, string workingOutput, string jsErrorSubstring, Regex[] stubbedAssemblies = null)
{
long elapsed, temp;
string generatedJs = null;
using (var test = new ComparisonTest(fileName, stubbedAssemblies)) {
var csOutput = test.RunCSharp(new string[0], out elapsed);
Assert.AreEqual(workingOutput, csOutput.Trim());
try {
test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed);
Assert.Fail("Expected javascript to throw an exception containing the string \"" + jsErrorSubstring + "\".");
} catch (JavaScriptException jse) {
if (!jse.ErrorText.Contains(jsErrorSubstring))
throw;
}
}
return generatedJs;
}
示例6: GetJavascript
protected string GetJavascript(string fileName, string expectedText = null)
{
long elapsed, temp;
string generatedJs = null, output;
using (var test = new ComparisonTest(fileName)) {
try {
output = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed);
} catch {
Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
throw;
}
if (expectedText != null)
Assert.AreEqual(expectedText, output.Trim());
}
return generatedJs;
}
示例7: GenericTest
protected string GenericTest(string fileName, string csharpOutput, string javascriptOutput, string[] stubbedAssemblies = null)
{
long elapsed, temp;
string generatedJs = null;
using (var test = new ComparisonTest(fileName, stubbedAssemblies)) {
var csOutput = test.RunCSharp(new string[0], out elapsed);
try {
var jsOutput = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed);
Assert.AreEqual(csharpOutput, csOutput.Trim(), "Did not get expected output from C# test");
Assert.AreEqual(javascriptOutput, jsOutput.Trim(), "Did not get expected output from JavaScript test");
} catch {
Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
throw;
}
}
return generatedJs;
}
示例8: GenericIgnoreTest
protected string GenericIgnoreTest(string fileName, string workingOutput, string jsErrorSubstring, string[] stubbedAssemblies = null)
{
long elapsed, temp;
string generatedJs = null, jsOutput = null;
using (var test = new ComparisonTest(EvaluatorPool, fileName, stubbedAssemblies)) {
var csOutput = test.RunCSharp(new string[0], out elapsed);
Assert.AreEqual(workingOutput, csOutput.Trim());
try {
jsOutput = test.RunJavascript(new string[0], out generatedJs, out temp, out elapsed);
Assert.Fail("Expected javascript to throw an exception containing the string \"" + jsErrorSubstring + "\".");
} catch (JavaScriptException jse) {
if (!jse.ErrorText.Contains(jsErrorSubstring)) {
Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
if (jsOutput != null)
Console.Error.WriteLine("// JS output: \r\n{0}", jsOutput);
throw;
}
} catch {
Console.Error.WriteLine("// Generated JS: \r\n{0}", generatedJs);
if (jsOutput != null)
Console.Error.WriteLine("// JS output: \r\n{0}", jsOutput);
throw;
}
}
return generatedJs;
}
示例9: PerformanceAnalysisData
public PerformanceAnalysisData (ComparisonTest test, Func<Configuration> makeConfiguration = null) {
string trailingOutput;
string stderr;
string tempS;
long tempL;
Output = test.RunJavascript(
null, out tempS, out tempL, out tempL, out stderr, out trailingOutput,
makeConfiguration: makeConfiguration
);
var singletonTypeIDs = new HashSet<UInt32>();
TaggedObjectTypesByID = ParseTaggedObjectTypes(stderr, trailingOutput, singletonTypeIDs);
TypeInformationByID = ParseTypeInformation(trailingOutput, TaggedObjectTypesByID, singletonTypeIDs);
TaggedObjectTypeIDsByName = new Dictionary<string, uint>(TaggedObjectTypesByID.Count);
foreach (var kvp in TaggedObjectTypesByID) {
if (!TaggedObjectTypeIDsByName.ContainsKey(kvp.Value))
TaggedObjectTypeIDsByName.Add(kvp.Value, kvp.Key);
}
RawStdErr = stderr;
RawTypeInformation = trailingOutput;
}