|
@@ -1442,10 +1442,11 @@ namespace Jint.Tests.Runtime
|
|
[Fact]
|
|
[Fact]
|
|
public void ShouldNotCatchClrExceptions()
|
|
public void ShouldNotCatchClrExceptions()
|
|
{
|
|
{
|
|
- Assert.ThrowsAny<NotSupportedException>(() => new Engine()
|
|
|
|
|
|
+ var engine = new Engine()
|
|
.SetValue("throwMyException", new Action(() => { throw new NotSupportedException(); }))
|
|
.SetValue("throwMyException", new Action(() => { throw new NotSupportedException(); }))
|
|
|
|
+ .SetValue("Thrower", typeof(Thrower))
|
|
.Execute(@"
|
|
.Execute(@"
|
|
- function throwException(){
|
|
|
|
|
|
+ function throwException1(){
|
|
try {
|
|
try {
|
|
throwMyException();
|
|
throwMyException();
|
|
return;
|
|
return;
|
|
@@ -1454,9 +1455,20 @@ namespace Jint.Tests.Runtime
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- ")
|
|
|
|
- .Invoke("throwException")
|
|
|
|
- );
|
|
|
|
|
|
+
|
|
|
|
+ function throwException2(){
|
|
|
|
+ try {
|
|
|
|
+ new Thrower().ThrowNotSupportedException();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ catch(e) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ");
|
|
|
|
+
|
|
|
|
+ Assert.ThrowsAny<NotSupportedException>(() => engine.Invoke("throwException1"));
|
|
|
|
+ Assert.ThrowsAny<NotSupportedException>(() => engine.Invoke("throwException2"));
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
@@ -1464,10 +1476,11 @@ namespace Jint.Tests.Runtime
|
|
{
|
|
{
|
|
string exceptionMessage = "myExceptionMessage";
|
|
string exceptionMessage = "myExceptionMessage";
|
|
|
|
|
|
- var result = new Engine(o => o.CatchClrExceptions())
|
|
|
|
|
|
+ var engine = new Engine(o => o.CatchClrExceptions())
|
|
.SetValue("throwMyException", new Action(() => { throw new Exception(exceptionMessage); }))
|
|
.SetValue("throwMyException", new Action(() => { throw new Exception(exceptionMessage); }))
|
|
|
|
+ .SetValue("Thrower", typeof(Thrower))
|
|
.Execute(@"
|
|
.Execute(@"
|
|
- function throwException(){
|
|
|
|
|
|
+ function throwException1(){
|
|
try {
|
|
try {
|
|
throwMyException();
|
|
throwMyException();
|
|
return '';
|
|
return '';
|
|
@@ -1476,10 +1489,20 @@ namespace Jint.Tests.Runtime
|
|
return e.message;
|
|
return e.message;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- ")
|
|
|
|
- .Invoke("throwException");
|
|
|
|
|
|
|
|
- Assert.Equal(result.AsString(), exceptionMessage);
|
|
|
|
|
|
+ function throwException2(){
|
|
|
|
+ try {
|
|
|
|
+ new Thrower().ThrowExceptionWithMessage('myExceptionMessage');
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ catch(e) {
|
|
|
|
+ return e.message;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ");
|
|
|
|
+
|
|
|
|
+ Assert.Equal(engine.Invoke("throwException1").AsString(), exceptionMessage);
|
|
|
|
+ Assert.Equal(engine.Invoke("throwException2").AsString(), exceptionMessage);
|
|
}
|
|
}
|
|
|
|
|
|
[Fact]
|
|
[Fact]
|
|
@@ -1490,6 +1513,7 @@ namespace Jint.Tests.Runtime
|
|
var engine = new Engine(o => o.CatchClrExceptions(e => e is NotSupportedException))
|
|
var engine = new Engine(o => o.CatchClrExceptions(e => e is NotSupportedException))
|
|
.SetValue("throwMyException1", new Action(() => { throw new NotSupportedException(exceptionMessage); }))
|
|
.SetValue("throwMyException1", new Action(() => { throw new NotSupportedException(exceptionMessage); }))
|
|
.SetValue("throwMyException2", new Action(() => { throw new ArgumentNullException(); }))
|
|
.SetValue("throwMyException2", new Action(() => { throw new ArgumentNullException(); }))
|
|
|
|
+ .SetValue("Thrower", typeof(Thrower))
|
|
.Execute(@"
|
|
.Execute(@"
|
|
function throwException1(){
|
|
function throwException1(){
|
|
try {
|
|
try {
|
|
@@ -1510,12 +1534,32 @@ namespace Jint.Tests.Runtime
|
|
return e.message;
|
|
return e.message;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- ");
|
|
|
|
|
|
|
|
- var result = engine.Invoke("throwException1");
|
|
|
|
|
|
+ function throwException3(){
|
|
|
|
+ try {
|
|
|
|
+ new Thrower().ThrowNotSupportedExceptionWithMessage('myExceptionMessage');
|
|
|
|
+ return '';
|
|
|
|
+ }
|
|
|
|
+ catch(e) {
|
|
|
|
+ return e.message;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- Assert.Equal(result.AsString(), exceptionMessage);
|
|
|
|
|
|
+ function throwException4(){
|
|
|
|
+ try {
|
|
|
|
+ new Thrower().ThrowArgumentNullException();
|
|
|
|
+ return '';
|
|
|
|
+ }
|
|
|
|
+ catch(e) {
|
|
|
|
+ return e.message;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ");
|
|
|
|
+
|
|
|
|
+ Assert.Equal(engine.Invoke("throwException1").AsString(), exceptionMessage);
|
|
Assert.Throws<ArgumentNullException>(() => engine.Invoke("throwException2"));
|
|
Assert.Throws<ArgumentNullException>(() => engine.Invoke("throwException2"));
|
|
|
|
+ Assert.Equal(engine.Invoke("throwException3").AsString(), exceptionMessage);
|
|
|
|
+ Assert.Throws<ArgumentNullException>(() => engine.Invoke("throwException4"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|