diff options
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration_tests.rs | 5 | ||||
-rw-r--r-- | cli/tests/runtime_decorators.ts | 42 | ||||
-rw-r--r-- | cli/tests/runtime_decorators.ts.out | 7 |
3 files changed, 54 insertions, 0 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index c99033020..aca2df99c 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -2927,6 +2927,11 @@ itest!(no_check_decorators { output: "no_check_decorators.ts.out", }); +itest!(runtime_decorators { + args: "run --quiet --reload --no-check runtime_decorators.ts", + output: "runtime_decorators.ts.out", +}); + itest!(lib_ref { args: "run --quiet --unstable --reload lib_ref.ts", output: "lib_ref.ts.out", diff --git a/cli/tests/runtime_decorators.ts b/cli/tests/runtime_decorators.ts new file mode 100644 index 000000000..5da109110 --- /dev/null +++ b/cli/tests/runtime_decorators.ts @@ -0,0 +1,42 @@ +// deno-lint-ignore-file +function A() { + console.log("@A evaluated"); + return function ( + target: any, + propertyKey: string, + descriptor: PropertyDescriptor, + ) { + console.log("@A called"); + const fn = descriptor.value; + descriptor.value = function () { + console.log("fn() called from @A"); + fn(); + }; + }; +} + +function B() { + console.log("@B evaluated"); + return function ( + target: any, + propertyKey: string, + descriptor: PropertyDescriptor, + ) { + console.log("@B called"); + const fn = descriptor.value; + descriptor.value = function () { + console.log("fn() called from @B"); + fn(); + }; + }; +} + +class C { + @A() + @B() + static test() { + console.log("C.test() called"); + } +} + +C.test(); diff --git a/cli/tests/runtime_decorators.ts.out b/cli/tests/runtime_decorators.ts.out new file mode 100644 index 000000000..0fc1d4590 --- /dev/null +++ b/cli/tests/runtime_decorators.ts.out @@ -0,0 +1,7 @@ +@A evaluated +@B evaluated +@B called +@A called +fn() called from @A +fn() called from @B +C.test() called |