Skip to content

Commit

Permalink
[CI] Add test for 11892
Browse files Browse the repository at this point in the history
  • Loading branch information
kLabz committed Jan 21, 2025
1 parent d5dd8f5 commit 5e07c06
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 0 deletions.
53 changes: 53 additions & 0 deletions tests/server/src/cases/display/issues/Issue11892.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package cases.display.issues;

import haxe.Json;
import haxe.display.Display;

private typedef HoverResponse = {
?error:{code:Int, message:String},
?result:HoverResult
}

class Issue11892 extends DisplayTestCase {
function testCompilerMetadata(_) {
var content = getTemplate("issues/Issue11892/Main.hx");
var transform = Marker.extractMarkers(content);
vfs.putContent("Main.hx", transform.source);

var args = ["--main", "Main", "-D", "analyzer-optimize", "--interp", "--dce=full"];
// Needed to repro -4-
args = args.concat(["-D", "disable-hxb-cache"]);
runHaxe(["--no-output"].concat(args));

// Previously was pointing to @:pure
runHaxeJson(args, DisplayMethods.Hover, {file: new FsPath("Main.hx"), offset: transform.markers[1]});
var response:HoverResponse = Json.parse(lastResult.stderr);
Assert.equals(null, response.error);
Assert.equals(null, response.result.result);

runHaxe(["--no-output"].concat(args));

// Previously was pointing to @:value
runHaxeJson(args, DisplayMethods.Hover, {file: new FsPath("Main.hx"), offset: transform.markers[2]});
var response:HoverResponse = Json.parse(lastResult.stderr);
Assert.equals(null, response.error);
Assert.equals(null, response.result.result);

runHaxe(["--no-output"].concat(args));

// Previously was pointing to @:pure(expect)
// But previously was also giving an error..
runHaxeJson(args, DisplayMethods.Hover, {file: new FsPath("Main.hx"), offset: transform.markers[3]});
var response:HoverResponse = Json.parse(lastResult.stderr);
Assert.equals(null, response.error);
Assert.equals(null, response.result?.result);

runHaxe(["--no-output"].concat(args));

// Previously was pointing to @:directlyUsed
runHaxeJson(args, DisplayMethods.Hover, {file: new FsPath("Main.hx"), offset: transform.markers[4]});
var response:HoverResponse = Json.parse(lastResult.stderr);
Assert.equals(null, response.error);
Assert.equals(null, response.result.result);
}
}
26 changes: 26 additions & 0 deletions tests/server/test/templates/issues/Issue11892/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class Main {
static function main():Void {
var pure {-1-}= 42;
}

var value = {
var y {-2-}= 42;
0;
};
}

class Foo {
@:pure function foo() {}
}

class PureExpect extends Foo {
override final function foo() {
var y {-3-}= 42;
}

function baz() trace(DirectlyUsedEnum);
}

enum DirectlyUsedEnum {
Foobar(a:Int {-4-}, b:Int);
}
2 changes: 2 additions & 0 deletions tests/server/test/templates/issues/Issue11892/build.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--main Main1a
--interp

0 comments on commit 5e07c06

Please sign in to comment.