Skip to content

PARTIAL: Support testing ResolutionException #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ public String getLocalizedMessage() {
public ScriptException toScriptException(ExecutionContext cx) {
throw Errors.newSyntaxError(cx, this, messageKey, messageArguments);
}

public String getScriptMessage(ExecutionContext cx) {
return Errors.newSyntaxError(cx, this, messageKey, messageArguments).getMessage(cx);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import com.github.anba.es6draft.runtime.ExecutionContext;
import com.github.anba.es6draft.runtime.internal.Messages;
import com.github.anba.es6draft.runtime.internal.ScriptException;
import com.github.anba.es6draft.runtime.modules.ResolutionException;

/**
* {@link Matcher} for script execution error messages.
Expand Down Expand Up @@ -54,6 +55,9 @@ private String getMessage(T error) {
if (error instanceof StackOverflowError) {
return String.format("InternalError: %s", cx.getRealm().message(Messages.Key.StackOverflow));
}
if (error instanceof ResolutionException) {
return ((ResolutionException) error).getScriptMessage(cx);
}
return error.getMessage();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.github.anba.es6draft.repl.global.StopExecutionException;
import com.github.anba.es6draft.runtime.ExecutionContext;
import com.github.anba.es6draft.runtime.internal.ScriptException;
import com.github.anba.es6draft.runtime.modules.ResolutionException;
import com.github.anba.es6draft.util.TestAssertions;

/**
Expand All @@ -42,12 +43,12 @@ private static <T> Iterable<T> asIterable(Supplier<Stream<T>> stream) {
}

/**
* {@link ExceptionHandler} for {@link ParserException}, {@link CompilationException} and {@link StackOverflowError}
* errors.
* {@link ExceptionHandler} for {@link ParserException}, {@link CompilationException}, {@link StackOverflowError}
* and {@link ResolutionException} errors.
*/
public static final class StandardErrorHandler extends ExceptionHandler {
private static final Matcher<Object> defaultMatcher = anyInstanceOf(ParserException.class,
CompilationException.class, StackOverflowError.class);
CompilationException.class, StackOverflowError.class, ResolutionException.class);

public StandardErrorHandler() {
this(defaultMatcher());
Expand Down Expand Up @@ -110,11 +111,12 @@ public static Matcher<Object> defaultMatcher() {

/**
* {@link ExceptionHandler} for {@link ParserException}, {@link CompilationException}, {@link StackOverflowError}
* and {@link ScriptException} errors.
* {@link ScriptException}, and {@link ResolutionException} errors.
*/
public static final class IgnoreExceptionHandler extends ExceptionHandler {
private static final Matcher<Object> defaultMatcher = anyInstanceOf(ParserException.class,
CompilationException.class, StackOverflowError.class, ScriptException.class);
CompilationException.class, StackOverflowError.class, ScriptException.class,
ResolutionException.class);

public IgnoreExceptionHandler() {
this(defaultMatcher());
Expand Down