File tree Expand file tree Collapse file tree
test/JavaScriptEngineSwitcher.Tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1047,5 +1047,34 @@ public virtual void GarbageCollection()
10471047 }
10481048
10491049 #endregion
1050+
1051+ #region Miscellaneous
1052+
1053+ [ Fact ]
1054+ public virtual void GettingFunctionSourceText ( )
1055+ {
1056+ // Arrange
1057+ const string functionCode = "function square(num) {\n " +
1058+ " return num * num;\n " +
1059+ "}"
1060+ ;
1061+
1062+ const string input = "square.toString()" ;
1063+ const string targetOutput = functionCode ;
1064+
1065+ // Act
1066+ string output ;
1067+
1068+ using ( var jsEngine = CreateJsEngine ( ) )
1069+ {
1070+ jsEngine . Execute ( functionCode ) ;
1071+ output = jsEngine . Evaluate < string > ( input ) ;
1072+ }
1073+
1074+ // Assert
1075+ Assert . Equal ( targetOutput , output ) ;
1076+ }
1077+
1078+ #endregion
10501079 }
10511080}
Original file line number Diff line number Diff line change @@ -256,5 +256,37 @@ public void GenerationOfRuntimeErrorMessage()
256256 #endregion
257257
258258 #endregion
259+
260+ #region Miscellaneous
261+
262+ [ Fact ]
263+ public override void GettingFunctionSourceText ( )
264+ {
265+ // Arrange
266+ const string functionCode = "function square(num) {\n " +
267+ " return num * num;\n " +
268+ "}"
269+ ;
270+
271+ const string input = "square.toString()" ;
272+ const string targetOutput = "function square(num) {\n \n " +
273+ " return num * num;\n \n " +
274+ "}"
275+ ;
276+
277+ // Act
278+ string output ;
279+
280+ using ( var jsEngine = CreateJsEngine ( ) )
281+ {
282+ jsEngine . Execute ( functionCode ) ;
283+ output = jsEngine . Evaluate < string > ( input ) ;
284+ }
285+
286+ // Assert
287+ Assert . Equal ( targetOutput , output ) ;
288+ }
289+
290+ #endregion
259291 }
260292}
Original file line number Diff line number Diff line change @@ -298,5 +298,34 @@ public void GenerationOfRuntimeErrorMessage()
298298 #endregion
299299
300300 #endregion
301+
302+ #region Miscellaneous
303+
304+ [ Fact ]
305+ public override void GettingFunctionSourceText ( )
306+ {
307+ // Arrange
308+ const string functionCode = "function square(num) {\n " +
309+ " return num * num;\n " +
310+ "}"
311+ ;
312+
313+ const string input = "square.toString()" ;
314+ const string targetOutput = "function" ;
315+
316+ // Act
317+ string output ;
318+
319+ using ( var jsEngine = CreateJsEngine ( ) )
320+ {
321+ jsEngine . Execute ( functionCode ) ;
322+ output = jsEngine . Evaluate < string > ( input ) ;
323+ }
324+
325+ // Assert
326+ Assert . Equal ( targetOutput , output ) ;
327+ }
328+
329+ #endregion
301330 }
302331}
You can’t perform that action at this time.
0 commit comments