-
Notifications
You must be signed in to change notification settings - Fork 323
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
Symetric, transitive and reflexive equality for intersection types #11897
Merged
+390
−74
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
24b40ce
EnsoMultiValue.== must be symetric, transitive and reflexive
JaroslavTulach db5353b
Any.to behaves like type cast
JaroslavTulach 7c653ba
Ordering of EnsoMultiValue compares all 'has been cast to' types
JaroslavTulach 308a2da
Hash of a multi value must be sum of hashes of its values
JaroslavTulach 4fabfbf
Adjusting dictionary example
JaroslavTulach b516371
Integer is the 42L precise type
JaroslavTulach 2f762c1
Avoid double wrapping of multi values
JaroslavTulach 5acb24b
Documenting equality and hash for intersection types
JaroslavTulach c17a45f
Merge branch 'develop' into wip/jtulach/TransitiveReflexiveEquals11845
mergify[bot] d30da41
2nd multi value argument conversions do not work
JaroslavTulach 02080f9
#11935: Ignoring tests for now
JaroslavTulach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
engine/runtime-integration-tests/src/test/java/org/enso/interpreter/test/AnyToTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package org.enso.interpreter.test; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.io.ByteArrayOutputStream; | ||
import java.nio.charset.StandardCharsets; | ||
import org.enso.interpreter.runtime.data.EnsoMultiValue; | ||
import org.enso.interpreter.runtime.data.Type; | ||
import org.enso.interpreter.runtime.data.text.Text; | ||
import org.enso.test.utils.ContextUtils; | ||
import org.graalvm.polyglot.Context; | ||
import org.graalvm.polyglot.Source; | ||
import org.junit.AfterClass; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
public class AnyToTest { | ||
private static Context ctx; | ||
|
||
private static final ByteArrayOutputStream out = new ByteArrayOutputStream(); | ||
|
||
@BeforeClass | ||
public static void initCtx() { | ||
ctx = ContextUtils.createDefaultContext(out); | ||
} | ||
|
||
@AfterClass | ||
public static void disposeCtx() { | ||
ctx.close(); | ||
ctx = null; | ||
} | ||
|
||
@Before | ||
public void resetOutput() { | ||
out.reset(); | ||
} | ||
|
||
private String getStdOut() { | ||
return out.toString(StandardCharsets.UTF_8); | ||
} | ||
|
||
@Test | ||
public void multiValueToInteger() throws Exception { | ||
var ensoCtx = ContextUtils.leakContext(ctx); | ||
var types = | ||
new Type[] {ensoCtx.getBuiltins().number().getInteger(), ensoCtx.getBuiltins().text()}; | ||
var code = | ||
""" | ||
from Standard.Base import all | ||
|
||
private eq a b = a == b | ||
|
||
conv style v = case style of | ||
0 -> v.to Integer | ||
1 -> v:Integer | ||
2 -> v.to Text | ||
3 -> v:Text | ||
99 -> eq | ||
|
||
"""; | ||
var conv = | ||
ContextUtils.evalModule(ctx, Source.newBuilder("enso", code, "conv.enso").build(), "conv"); | ||
var both = EnsoMultiValue.create(types, types.length, new Object[] {2L, Text.create("Two")}); | ||
var eq = | ||
ContextUtils.executeInContext( | ||
ctx, | ||
() -> { | ||
var bothValue = ctx.asValue(both); | ||
var asIntegerTo = conv.execute(0, bothValue); | ||
var asIntegerCast = conv.execute(1, bothValue); | ||
var equals = conv.execute(99, null); | ||
return equals.execute(asIntegerTo, asIntegerCast); | ||
}); | ||
assertTrue("Any.to and : give the same result", eq.asBoolean()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like you forgot to test style 2 and 3, i.e.:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, not only it is not called, but it is also broken. These two new tests added in d30da41 are failing on CI
multi_value.to
doesn't work on second & further elements of intersection type #11935