--- a/RegressionTests__JavaScriptTests.st Thu Mar 16 13:59:18 2006 +0100
+++ b/RegressionTests__JavaScriptTests.st Thu Mar 16 15:24:19 2006 +0100
@@ -436,17 +436,38 @@
testException01
self
- execute:'test(arr) {
+ execute:'test() {
try {
- } catch
+ return 10;
+ } catch(Error);
+ return nil;
}'
for:nil
- arguments:#( #(10 20 30) )
+ arguments:#( )
expect:10
"
- self run:#testArray01
- self new testArray01
+ self run:#testException01
+ self new testException01
+ "
+!
+
+testException02
+ self
+ execute:'test() {
+ try {
+ Error.raise();
+ return 10;
+ } catch(Error);
+ return nil;
+ }'
+ for:nil
+ arguments:#( )
+ expect:nil
+
+ "
+ self run:#testException02
+ self new testException02
"
!
@@ -2544,9 +2565,6 @@
!
testOperators46_comma
- "the right part of a logical or should not be evaluated,
- if the left is already true"
-
self
execute:'expr(a, b, c) {
var x;
@@ -2619,6 +2637,29 @@
"
!
+testOperators47_asString
+ self
+ execute:'expr() {
+ return 123.asString;
+ }'
+ for:nil
+ arguments:#()
+ expect:'123'.
+
+ self
+ execute:'expr() {
+ return 1.23.asString;
+ }'
+ for:nil
+ arguments:#()
+ expect:'1.23'.
+
+ "
+ self run:#testOperators47_toString
+ self new testOperators47_toString
+ "
+!
+
testPrecidences01
self
execute:'expr(a, b) {
@@ -3449,6 +3490,183 @@
"
!
+testTryCatch01a
+ self
+ execute:'test(arg) {
+ var handlerWasCalled = false;
+
+ function failingMethod() { return 10 / arg; };
+
+ try {
+ failingMethod();
+ } catch (Error e) {
+ handlerWasCalled = true;
+ }
+ return handlerWasCalled;
+ }'
+ for:nil
+ arguments:#(5)
+ expect:false
+
+ "
+ self run:#testTryCatch01a
+ self new testTryCatch01a
+ "
+!
+
+testTryCatch01b
+ self
+ execute:'test(arg) {
+ var handlerWasCalled = false;
+
+ function failingMethod() { return 10 / arg; };
+
+ try {
+ failingMethod();
+ } catch (Error e) {
+ handlerWasCalled = true;
+ }
+ return handlerWasCalled;
+ }'
+ for:nil
+ arguments:#(0)
+ expect:true
+
+ "
+ self run:#testTryCatch01b
+ self new testTryCatch01b
+ "
+!
+
+testTryCatch02a
+ self
+ execute:'test(arg) {
+ var handlerWasCalled = false;
+
+ function failingMethod() { return 10 / arg; };
+ function exceptionRaised() { handlerWasCalled = true; };
+
+ try {
+ failingMethod();
+ } catch (Error e) {
+ exceptionRaised();
+ }
+ return handlerWasCalled;
+ }'
+ for:nil
+ arguments:#(5)
+ expect:false
+
+ "
+ self run:#testTryCatch02a
+ self new testTryCatch02a
+ "
+!
+
+testTryCatch02b
+ self
+ execute:'test(arg) {
+ var handlerWasCalled = false;
+
+ function failingMethod() { return 10 / arg; };
+ function exceptionRaised() { handlerWasCalled = true; };
+
+ try {
+ failingMethod();
+ } catch (Error e) {
+ exceptionRaised();
+ }
+ return handlerWasCalled;
+ }'
+ for:nil
+ arguments:#(0)
+ expect:true
+
+ "
+ self run:#testTryCatch02b
+ self new testTryCatch02b
+ "
+!
+
+testTryCatch03a
+ self
+ execute:'test(arg) {
+ var handlerWasCalled = false;
+
+ function failingMethod() { return 10 / arg; };
+ function exceptionRaised(e) { handlerWasCalled = true; };
+
+ try {
+ failingMethod();
+ } catch (Error e) {
+ exceptionRaised(e);
+ }
+ return handlerWasCalled;
+ }'
+ for:nil
+ arguments:#(5)
+ expect:false
+
+ "
+ self run:#testTryCatch03a
+ self new testTryCatch03a
+ "
+!
+
+testTryCatch03b
+ self
+ execute:'test(arg) {
+ var handlerWasCalled = false;
+
+ function failingMethod() { return 10 / arg; };
+ function exceptionRaised(e) { this.halt(); handlerWasCalled = true; };
+
+ try {
+ failingMethod();
+ } catch (Error e) {
+ exceptionRaised(e);
+ }
+ return handlerWasCalled;
+ }'
+ for:nil
+ arguments:#(0)
+ expect:true
+
+ "
+ self run:#testTryCatch03b
+ self new testTryCatch03b
+ "
+!
+
+testTryCatch04b
+ self should:[
+
+ self
+ execute:'test(arg) {
+ var handlerWasCalled = false;
+
+ function failingMethod() { return 10 / arg; };
+ function exceptionRaised() { handlerWasCalled = true; };
+
+ try {
+ failingMethod();
+ } catch (Error e) {
+ exceptionRaised(e);
+ }
+ return handlerWasCalled;
+ }'
+ for:nil
+ arguments:#(0)
+ expect:true
+
+ ] raise: Error.
+
+ "
+ self run:#testTryCatch04b
+ self new testTryCatch04b
+ "
+!
+
testVarDeclaration01
self
execute:'expr(a, b) {