|
| 1 | +//------------------------------------------------------------------------------------------------------- |
| 2 | +// Copyright (C) Microsoft. All rights reserved. |
| 3 | +// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information. |
| 4 | +//------------------------------------------------------------------------------------------------------- |
| 5 | + |
| 6 | +WScript.LoadScriptFile("..\\UnitTestFramework\\UnitTestFramework.js"); |
| 7 | + |
| 8 | +var tests = [ |
| 9 | + { |
| 10 | + name: "Expect exception with invalid file name to WScript.LoadScript", |
| 11 | + body: function () { |
| 12 | + assert.throws(function () { |
| 13 | + WScript.LoadScript(``, ``, { |
| 14 | + toString: function () { |
| 15 | + func_0(); |
| 16 | + }} |
| 17 | + ); |
| 18 | + }, Error, |
| 19 | + "Should throw for invalid input to WScript.LoadScript", |
| 20 | + "ScriptError"); |
| 21 | + } |
| 22 | + }, |
| 23 | + { |
| 24 | + name: "Expect exception with invalid type to WScript.LoadScript", |
| 25 | + body: function () { |
| 26 | + assert.throws(function () { |
| 27 | + WScript.LoadScript(``, { |
| 28 | + toString: function () { |
| 29 | + func_0(); |
| 30 | + }}, `` |
| 31 | + ); |
| 32 | + }, Error, |
| 33 | + "Should throw for invalid input to WScript.LoadScript", |
| 34 | + "ScriptError"); |
| 35 | + } |
| 36 | + }, |
| 37 | + { |
| 38 | + name: "Expect exception with invalid content to WScript.LoadScript", |
| 39 | + body: function () { |
| 40 | + assert.throws(function () { |
| 41 | + WScript.LoadScript({ |
| 42 | + toString: function () { |
| 43 | + func_0(); |
| 44 | + }}, ``, `` |
| 45 | + ); |
| 46 | + }, Error, |
| 47 | + "Should throw for invalid input to WScript.LoadScript", |
| 48 | + "ScriptError"); |
| 49 | + } |
| 50 | + }, |
| 51 | + { |
| 52 | + name: "Expect exception with invalid file name to WScript.LoadModule", |
| 53 | + body: function () { |
| 54 | + assert.throws(function () { |
| 55 | + WScript.LoadModule(``, ``, { |
| 56 | + toString: function () { |
| 57 | + func_0(); |
| 58 | + }} |
| 59 | + ); |
| 60 | + }, Error, |
| 61 | + "Should throw for invalid input to WScript.LoadModule", |
| 62 | + "ScriptError"); |
| 63 | + } |
| 64 | + }, |
| 65 | + { |
| 66 | + name: "Expect exception with invalid type to WScript.LoadModule", |
| 67 | + body: function () { |
| 68 | + assert.throws(function () { |
| 69 | + WScript.LoadModule(``, { |
| 70 | + toString: function () { |
| 71 | + func_0(); |
| 72 | + }}, `` |
| 73 | + ); |
| 74 | + }, Error, |
| 75 | + "Should throw for invalid input to WScript.LoadModule", |
| 76 | + "ScriptError"); |
| 77 | + } |
| 78 | + }, |
| 79 | + { |
| 80 | + name: "Expect exception with invalid content to WScript.LoadModule", |
| 81 | + body: function () { |
| 82 | + assert.throws(function () { |
| 83 | + WScript.LoadModule({ |
| 84 | + toString: function () { |
| 85 | + func_0(); |
| 86 | + }}, ``, `` |
| 87 | + ); |
| 88 | + }, Error, |
| 89 | + "Should throw for invalid input to WScript.LoadModule", |
| 90 | + "ScriptError"); |
| 91 | + } |
| 92 | + }, |
| 93 | +]; |
| 94 | + |
| 95 | +testRunner.runTests(tests, { verbose: WScript.Arguments[0] != "summary" }); |
0 commit comments