1- using NUnit . Framework ;
1+ using System ;
2+
3+ using NUnit . Framework ;
24
35using MsieJavaScriptEngine . Test . Common ;
46
@@ -7,10 +9,11 @@ namespace MsieJavaScriptEngine.Test.ChakraActiveScript
79 [ TestFixture ]
810 public class CommonTests : CommonTestsBase
911 {
10- protected override MsieJsEngine CreateJsEngine ( )
12+ protected override MsieJsEngine CreateJsEngine ( bool enableDebugging )
1113 {
1214 var jsEngine = new MsieJsEngine ( new JsEngineSettings
1315 {
16+ EnableDebugging = enableDebugging ,
1417 EngineMode = JsEngineMode . ChakraActiveScript ,
1518 UseEcmaScript5Polyfill = false ,
1619 UseJson2Library = false
@@ -21,6 +24,106 @@ protected override MsieJsEngine CreateJsEngine()
2124
2225 #region Mapping errors
2326
27+ [ Test ]
28+ public void GenerationOfParseErrorMessageIsCorrect ( )
29+ {
30+ // Arrange
31+ const string input = @"var arr = [];
32+ var obj = {};
33+ var foo = 'Browser's bar';" ;
34+ string targetOutput = "Compilation error: Expected ';'" + Environment . NewLine +
35+ " at 3:20"
36+ ;
37+
38+ JsException exception = null ;
39+
40+ // Act
41+ using ( var jsEngine = CreateJsEngine ( ) )
42+ {
43+ try
44+ {
45+ jsEngine . Execute ( input , "variables.js" ) ;
46+ }
47+ catch ( JsRuntimeException e )
48+ {
49+ exception = e ;
50+ }
51+ }
52+
53+ Assert . NotNull ( exception ) ;
54+ Assert . IsNotEmpty ( exception . Message ) ;
55+ Assert . AreEqual ( targetOutput , exception . Message ) ;
56+ }
57+
58+ [ Test ]
59+ public void GenerationOfParseErrorMessageInDebugModeIsCorrect ( )
60+ {
61+ // Arrange
62+ const string input = @"var arr = [];
63+ var obj = {};
64+ var foo = 'Browser's bar';" ;
65+ string targetOutput = "Compilation error: Expected ';'" + Environment . NewLine +
66+ " at variables.js:3:20"
67+ ;
68+
69+ JsException exception = null ;
70+
71+ // Act
72+ using ( var jsEngine = CreateJsEngine ( true ) )
73+ {
74+ try
75+ {
76+ jsEngine . Execute ( input , "variables.js" ) ;
77+ }
78+ catch ( JsRuntimeException e )
79+ {
80+ exception = e ;
81+ }
82+ }
83+
84+ Assert . NotNull ( exception ) ;
85+ Assert . IsNotEmpty ( exception . Message ) ;
86+ Assert . AreEqual ( targetOutput , exception . Message ) ;
87+ }
88+
89+ [ Test ]
90+ public void GenerationOfRuntimeErrorMessageIsCorrect ( )
91+ {
92+ // Arrange
93+ const string input = @"function foo(x, y) {
94+ var z = x + y;
95+ if (z > 20) {
96+ bar();
97+ }
98+ }
99+
100+ var a = 8;
101+ var b = 15;
102+
103+ foo(a, b);" ;
104+ string targetOutput = "Runtime error: 'bar' is undefined" + Environment . NewLine +
105+ " at 4:3" ;
106+
107+ JsException exception = null ;
108+
109+ // Act
110+ using ( var jsEngine = CreateJsEngine ( ) )
111+ {
112+ try
113+ {
114+ jsEngine . Execute ( input , "functions.js" ) ;
115+ }
116+ catch ( JsRuntimeException e )
117+ {
118+ exception = e ;
119+ }
120+ }
121+
122+ Assert . NotNull ( exception ) ;
123+ Assert . IsNotEmpty ( exception . Message ) ;
124+ Assert . AreEqual ( targetOutput , exception . Message ) ;
125+ }
126+
24127 [ Test ]
25128 public override void MappingRuntimeErrorDuringEvaluationOfExpressionIsCorrect ( )
26129 {
0 commit comments