Skip to content

Commit

Permalink
test private_field_presence
Browse files Browse the repository at this point in the history
  • Loading branch information
kitsonk committed Dec 9, 2021
1 parent 1d475ce commit f5afd67
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cli/tests/integration/run_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,16 @@ itest!(import_type_no_check {
output: "import_type.ts.out",
});

itest!(private_field_presence {
args: "run --reload private_field_presence.ts",
output: "private_field_presence.ts.out",
});

itest!(private_field_presence_no_check {
args: "run --reload --no-check private_field_presence.ts",
output: "private_field_presence.ts.out",
});

itest!(lock_write_requires_lock {
args: "run --lock-write some_file.ts",
output: "lock_write_requires_lock.out",
Expand Down
5 changes: 5 additions & 0 deletions cli/tests/testdata/import_type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { type B, create } from "./subdir/export_types.ts";

const b: B = create();

console.log(b);
2 changes: 2 additions & 0 deletions cli/tests/testdata/import_type.ts.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[WILDCARD]
B { a: "a" }
20 changes: 20 additions & 0 deletions cli/tests/testdata/private_field_presence.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export class Person {
#name: string;
constructor(name: string) {
this.#name = name;
}

equals(other: unknown) {
return other &&
typeof other === "object" &&
#name in other &&
this.#name === other.#name;
}
}

const a = new Person("alice");
const b = new Person("bob");
const c = new Person("alice");

console.log(a.equals(b));
console.log(a.equals(c));
3 changes: 3 additions & 0 deletions cli/tests/testdata/private_field_presence.ts.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[WILDCARD]
false
true
11 changes: 11 additions & 0 deletions cli/tests/testdata/subdir/export_types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export interface A {
a: string;
}

export class B implements A {
a = "a";
}

export function create(): B {
return new B();
}

0 comments on commit f5afd67

Please sign in to comment.