mirror of
https://github.com/enso-org/enso.git
synced 2024-12-22 21:01:37 +03:00
Warning exports WarningsLibrary
This commit is contained in:
parent
62aefe54cc
commit
a06c672db5
@ -2,6 +2,7 @@ package org.enso.interpreter.test;
|
|||||||
|
|
||||||
import static org.hamcrest.MatcherAssert.assertThat;
|
import static org.hamcrest.MatcherAssert.assertThat;
|
||||||
import static org.hamcrest.Matchers.containsString;
|
import static org.hamcrest.Matchers.containsString;
|
||||||
|
import static org.hamcrest.Matchers.is;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@ -12,6 +13,7 @@ import org.enso.common.MethodNames;
|
|||||||
import org.enso.interpreter.runtime.EnsoContext;
|
import org.enso.interpreter.runtime.EnsoContext;
|
||||||
import org.enso.interpreter.runtime.warning.AppendWarningNode;
|
import org.enso.interpreter.runtime.warning.AppendWarningNode;
|
||||||
import org.enso.interpreter.runtime.warning.Warning;
|
import org.enso.interpreter.runtime.warning.Warning;
|
||||||
|
import org.enso.interpreter.runtime.warning.WarningsLibrary;
|
||||||
import org.enso.interpreter.runtime.warning.WithWarnings;
|
import org.enso.interpreter.runtime.warning.WithWarnings;
|
||||||
import org.enso.test.utils.ContextUtils;
|
import org.enso.test.utils.ContextUtils;
|
||||||
import org.graalvm.polyglot.Context;
|
import org.graalvm.polyglot.Context;
|
||||||
@ -194,4 +196,11 @@ public class WarningsTest {
|
|||||||
assertEquals(
|
assertEquals(
|
||||||
"Standard.Base.Error.Error", errorWithWarning.getMetaObject().getMetaQualifiedName());
|
"Standard.Base.Error.Error", errorWithWarning.getMetaObject().getMetaQualifiedName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void warningIsWarning_ViaWarningsLibrary() {
|
||||||
|
var warn = wrap.execute("Warning", 42L);
|
||||||
|
var warnsLib = WarningsLibrary.getUncached();
|
||||||
|
assertThat(warnsLib.hasWarnings(warn), is(true));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ import org.enso.interpreter.runtime.library.dispatch.TypesLibrary;
|
|||||||
|
|
||||||
@Builtin(pkg = "error", stdlibName = "Standard.Base.Warning.Warning")
|
@Builtin(pkg = "error", stdlibName = "Standard.Base.Warning.Warning")
|
||||||
@ExportLibrary(TypesLibrary.class)
|
@ExportLibrary(TypesLibrary.class)
|
||||||
|
@ExportLibrary(WarningsLibrary.class)
|
||||||
@ExportLibrary(value = InteropLibrary.class, delegateTo = "value")
|
@ExportLibrary(value = InteropLibrary.class, delegateTo = "value")
|
||||||
public final class Warning extends EnsoObject {
|
public final class Warning extends EnsoObject {
|
||||||
final Object value;
|
final Object value;
|
||||||
@ -133,6 +134,27 @@ public final class Warning extends EnsoObject {
|
|||||||
return EnsoContext.get(node).getBuiltins().warning();
|
return EnsoContext.get(node).getBuiltins().warning();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ExportMessage
|
||||||
|
boolean hasWarnings() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExportMessage
|
||||||
|
EnsoHashMap getWarnings(boolean shouldWrap, @Cached HashMapInsertNode insertNode) {
|
||||||
|
var map = insertNode.execute(null, EnsoHashMap.empty(), 0, this);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExportMessage
|
||||||
|
Object removeWarnings() throws UnsupportedMessageException {
|
||||||
|
throw UnsupportedMessageException.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
@ExportMessage
|
||||||
|
boolean isLimitReached() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static Warning wrapMapError(WarningsLibrary warningsLib, Warning warning, long index) {
|
public static Warning wrapMapError(WarningsLibrary warningsLib, Warning warning, long index) {
|
||||||
var ctx = EnsoContext.get(warningsLib);
|
var ctx = EnsoContext.get(warningsLib);
|
||||||
var error = warning.getValue();
|
var error = warning.getValue();
|
||||||
|
Loading…
Reference in New Issue
Block a user