diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/tests/ecma_6/Statements/try-completion.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/ecma_6/Statements/try-completion.js')
-rw-r--r-- | js/src/tests/ecma_6/Statements/try-completion.js | 482 |
1 files changed, 482 insertions, 0 deletions
diff --git a/js/src/tests/ecma_6/Statements/try-completion.js b/js/src/tests/ecma_6/Statements/try-completion.js new file mode 100644 index 000000000..f9bd1e149 --- /dev/null +++ b/js/src/tests/ecma_6/Statements/try-completion.js @@ -0,0 +1,482 @@ +var BUGNUMBER = 819125; +var summary = "try block should return try value if finally returned normally"; + +print(BUGNUMBER + ": " + summary); + +function expectTryValue(code, isUndefined) { + assertEq(eval(code), isUndefined ? undefined : 'try'); +} + +function expectCatchValue(code, isUndefined) { + assertEq(eval(code), isUndefined ? undefined : 'catch'); +} + +function expectFinallyValue(code, isUndefined) { + assertEq(eval(code), isUndefined ? undefined : 'finally'); +} + +// ==== finally: normal ==== + +// try: normal +// finally: normal +expectTryValue(` +try { + 'try'; +} finally { + 'finally'; +} +`); + +// try: normal without value +// finally: normal +expectTryValue(` +try { +} finally { + 'finally'; +} +`, true); + +// try: break +// finally: normal +expectTryValue(` +while (true) { + try { + 'try'; + break; + } finally { + 'finally'; + } +} +`); + +// try: break without value +// finally: normal +expectTryValue(` +while (true) { + try { + break; + } finally { + 'finally'; + } +} +`, true); + +// try: continue +// finally: normal +expectTryValue(` +do { + try { + 'try'; + continue; + } finally { + 'finally'; + } +} while (false); +`); + +// try: continue without value +// finally: normal +expectTryValue(` +do { + try { + continue; + } finally { + 'finally'; + } +} while (false); +`, true); + +// try: throw +// catch: normal +// finally: normal +expectCatchValue(` +try { + 'try'; + throw 'exception'; +} catch (e) { + 'catch'; +} finally { + 'finally'; +} +`); + +// try: throw +// catch: normal +// finally: normal +expectCatchValue(` +try { + 'try'; + throw 'exception'; +} catch (e) { + 'catch'; +} finally { + 'finally'; +} +`); + +// try: throw +// catch: normal without value +// finally: normal +expectCatchValue(` +try { + 'try'; + throw 'exception'; +} catch (e) { +} finally { + 'finally'; +} +`, true); + +// try: throw +// catch: normal without value +// finally: normal +expectCatchValue(` +try { + 'try'; + throw 'exception'; +} catch (e) { +} finally { + 'finally'; +} +`, true); + +// try: throw +// catch: break +// finally: normal +expectCatchValue(` +while (true) { + try { + 'try'; + throw 'exception'; + } catch (e) { + 'catch'; + break; + } finally { + 'finally'; + } +} +`); + +// try: throw +// catch: break without value +// finally: normal +expectCatchValue(` +while (true) { + try { + 'try'; + throw 'exception'; + } catch (e) { + break; + } finally { + 'finally'; + } +} +`, true); + +// try: throw +// catch: continue +// finally: normal +expectCatchValue(` +do { + try { + 'try'; + throw 'exception'; + } catch (e) { + 'catch'; + continue; + } finally { + 'finally'; + } +} while (false); +`); + +// try: throw +// catch: continue without value +// finally: normal +expectCatchValue(` +do { + try { + 'try'; + throw 'exception'; + } catch (e) { + continue; + } finally { + 'finally'; + } +} while (false); +`, true); + +// ==== finally: break ==== + +// try: normal +// finally: break +expectFinallyValue(` +while (true) { + try { + 'try'; + } finally { + 'finally'; + break; + } +} +`); + +// try: normal +// finally: break without value +expectFinallyValue(` +while (true) { + try { + 'try'; + } finally { + break; + } +} +`, true); + +// try: break +// finally: break +expectFinallyValue(` +while (true) { + try { + 'try'; + break; + } finally { + 'finally'; + break; + } +} +`); + +// try: break +// finally: break without value +expectFinallyValue(` +while (true) { + try { + 'try'; + break; + } finally { + break; + } +} +`, true); + +// try: continue +// finally: break +expectFinallyValue(` +do { + try { + 'try'; + continue; + } finally { + 'finally'; + break; + } +} while (false); +`); + +// try: continue +// finally: break without value +expectFinallyValue(` +do { + try { + 'try'; + continue; + } finally { + break; + } +} while (false); +`, true); + +// try: throw +// catch: normal +// finally: break +expectFinallyValue(` +while (true) { + try { + 'try'; + throw 'exception'; + } catch (e) { + 'catch'; + } finally { + 'finally'; + break; + } +} +`, false); + +// try: throw +// catch: normal +// finally: break without value +expectFinallyValue(` +while (true) { + try { + 'try'; + throw 'exception'; + } catch (e) { + 'catch'; + } finally { + break; + } +} +`, true); + +// ==== finally: continue ==== + +// try: normal +// finally: continue +expectFinallyValue(` +do { + try { + 'try'; + } finally { + 'finally'; + continue; + } +} while (false); +`); + +// try: normal +// finally: continue without value +expectFinallyValue(` +do { + try { + 'try'; + } finally { + continue; + } +} while (false); +`, true); + +// try: break +// finally: continue +expectFinallyValue(` +do { + try { + 'try'; + break; + } finally { + 'finally'; + continue; + } +} while (false); +`); + +// try: break +// finally: continue without value +expectFinallyValue(` +do { + try { + 'try'; + break; + } finally { + continue; + } +} while (false); +`, true); + +// try: continue +// finally: continue +expectFinallyValue(` +do { + try { + 'try'; + continue; + } finally { + 'finally'; + continue; + } +} while (false); +`); + +// try: continue +// finally: continue without value +expectFinallyValue(` +do { + try { + 'try'; + continue; + } finally { + continue; + } +} while (false); +`, true); + +// ==== without finally ==== + +// try: throw +// catch: normal +expectCatchValue(` +try { + 'try'; + throw 'exception'; +} catch (e) { + 'catch'; +} +`); + +// try: throw +// catch: normal without value +expectCatchValue(` +try { + 'try'; + throw 'exception'; +} catch (e) { +} +`, true); + +// try: throw +// catch: break +expectCatchValue(` +while (true) { + try { + 'try'; + throw 'exception'; + } catch (e) { + 'catch'; + break; + } +} +`); + +// try: throw +// catch: break without value +expectCatchValue(` +while (true) { + try { + 'try'; + throw 'exception'; + } catch (e) { + break; + } +} +`, true); + +// try: throw +// catch: continue +expectCatchValue(` +do { + try { + 'try'; + throw 'exception'; + } catch (e) { + 'catch'; + continue; + } +} while (false); +`); + +// try: throw +// catch: continue without value +expectCatchValue(` +do { + try { + 'try'; + throw 'exception'; + } catch (e) { + continue; + } +} while (false); +`, true); + +if (typeof reportCompare === "function") + reportCompare(true, true); |