OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 | 84 |
85 function assertNaN(value, name_opt) { | 85 function assertNaN(value, name_opt) { |
86 if (!isNaN(value)) { | 86 if (!isNaN(value)) { |
87 fail("NaN", value, name_opt); | 87 fail("NaN", value, name_opt); |
88 } | 88 } |
89 } | 89 } |
90 | 90 |
91 | 91 |
92 function assertThrows(code) { | 92 function assertThrows(code) { |
| 93 var threwException = true; |
93 try { | 94 try { |
94 eval(code); | 95 eval(code); |
95 assertTrue(false, "did not throw exception"); | 96 threwException = false; |
96 } catch (e) { | 97 } catch (e) { |
97 // Do nothing. | 98 // Do nothing. |
98 } | 99 } |
| 100 if (!threwException) assertTrue(false, "did not throw exception"); |
99 } | 101 } |
100 | 102 |
101 | 103 |
102 function assertInstanceof(obj, type) { | 104 function assertInstanceof(obj, type) { |
103 if (!(obj instanceof type)) { | 105 if (!(obj instanceof type)) { |
104 assertTrue(false, "Object <" + obj + "> is not an instance of <" + type + ">
"); | 106 assertTrue(false, "Object <" + obj + "> is not an instance of <" + type + ">
"); |
105 } | 107 } |
106 } | 108 } |
107 | 109 |
108 | 110 |
109 function assertDoesNotThrow(code) { | 111 function assertDoesNotThrow(code) { |
110 try { | 112 try { |
111 eval(code); | 113 eval(code); |
112 } catch (e) { | 114 } catch (e) { |
113 assertTrue(false, "threw an exception"); | 115 assertTrue(false, "threw an exception"); |
114 } | 116 } |
115 } | 117 } |
116 | 118 |
117 | 119 |
118 function assertUnreachable(name_opt) { | 120 function assertUnreachable(name_opt) { |
119 // Fix this when we ditch the old test runner. | 121 // Fix this when we ditch the old test runner. |
120 var message = "Fail" + "ure: unreachable" | 122 var message = "Fail" + "ure: unreachable" |
121 if (name_opt) { | 123 if (name_opt) { |
122 message += " - " + name_opt; | 124 message += " - " + name_opt; |
123 } | 125 } |
124 throw new MjsUnitAssertionError(message); | 126 throw new MjsUnitAssertionError(message); |
125 } | 127 } |
OLD | NEW |