Skip to content

Commit

Permalink
Add test for attribute invalidation
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Apr 3, 2024
1 parent 7cdfcc9 commit 06a24c0
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/diff/testOnlyCall/a/attribute.hack
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Hakana;

/**
* Used to denote a function that's only meant to be used in tests.
* Everything in hakana.json's test_files field is already considered test-only.
* This attribute should be used when test functions/classes live in the same file
* as production functions & classes
*/
final class TestOnly implements \HH\FunctionAttribute, \HH\ClassAttribute, \HH\MethodAttribute {
public function __construct() {}
}
12 changes: 12 additions & 0 deletions tests/diff/testOnlyCall/a/input.hack
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<<__EntryPoint>>
function main(): void {
test_fn();
other_fn();
}

<<Hakana\TestOnly>>
function test_fn(): void {}

function other_fn(): void {
test_fn();
}
11 changes: 11 additions & 0 deletions tests/diff/testOnlyCall/b/attribute.hack
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace Hakana;

/**
* Used to denote a function that's only meant to be used in tests.
* Everything in hakana.json's test_files field is already considered test-only.
* This attribute should be used when test functions/classes live in the same file
* as production functions & classes
*/
final class TestOnly implements \HH\FunctionAttribute, \HH\ClassAttribute, \HH\MethodAttribute {
public function __construct() {}
}
13 changes: 13 additions & 0 deletions tests/diff/testOnlyCall/b/input.hack
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<<__EntryPoint, Hakana\TestOnly>>
function main(): void {
test_fn();
other_fn();
}

<<Hakana\TestOnly>>
function test_fn(): void {}

<<Hakana\TestOnly>>
function other_fn(): void {
test_fn();
}
Empty file.

0 comments on commit 06a24c0

Please sign in to comment.