Skip to content

Commit 6cea7c0

Browse files
Add tests for EXTEND.
1 parent 63d8501 commit 6cea7c0

39 files changed

Lines changed: 1048 additions & 9 deletions
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
IMPORT(path)
2+
3+
STR: tests_dir = path.BASEPATH(path.BASEPATH(path.script_dir))
4+
STR: helper_path = JOIN(tests_dir, "/helpers/extend_core_once.pre")
5+
6+
IMPORT_PATH(helper_path, helper)
7+
8+
helper.extend_core.TST_EXT_ASMODULE_ONLY()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXTEND(prefix_missing_extension_target)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
IMPORT(path)
2+
3+
STR: tests_dir = path.BASEPATH(path.BASEPATH(path.script_dir))
4+
STR: helper_path = JOIN(tests_dir, "/helpers/extend_missing_init_loader.pre")
5+
6+
IMPORT_PATH(helper_path)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
IMPORT(path)
2+
3+
STR: tests_dir = path.BASEPATH(path.BASEPATH(path.script_dir))
4+
STR: helper_path = JOIN(tests_dir, "/helpers/extend_missing_package_loader.pre")
5+
6+
IMPORT_PATH(helper_path)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
IMPORT(path)
2+
3+
STR: tests_dir = path.BASEPATH(path.BASEPATH(path.script_dir))
4+
STR: helper_path = JOIN(tests_dir, "/helpers/extend_prex_loader.pre")
5+
6+
IMPORT_PATH(helper_path)
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
IMPORT(path)
2+
3+
STR: tests_dir = path.BASEPATH(path.BASEPATH(path.script_dir))
4+
STR: helper_path = JOIN(tests_dir, "/helpers/extend_core_once.pre")
5+
6+
IMPORT_PATH(helper_path, helper)
7+
8+
TST_EXT_RESTRICTED()
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
IMPORT(path)
2+
3+
STR: tests_dir = path.BASEPATH(path.BASEPATH(path.script_dir))
4+
STR: helper_path = JOIN(tests_dir, "/helpers/extend_core_once.pre")
5+
6+
ASSERT(NOT(IMPORT_PATH(helper_path, first)))
7+
ASSERT(NOT(IMPORT_PATH(helper_path, second)))
8+
ASSERT(EQ(first.extend_core.TST_EXT_RESTRICTED(), "core-restricted"))
9+
ASSERT(EQ(second.extend_core.TST_EXT_RESTRICTED(), "core-restricted"))
10+
ASSERT(EQ(TST_EXT_INIT_COUNT(), 0d1))
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
IMPORT(path)
2+
3+
STR: tests_dir = path.BASEPATH(path.BASEPATH(path.script_dir))
4+
STR: helper_path = JOIN(tests_dir, "/helpers/extend_core_once.pre")
5+
6+
ASSERT(NOT(IMPORT_PATH(helper_path, helper)))
7+
ASSERT(EQ(TST_EXT_ASMODULE_ONLY(), "asmodule-global"))
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
$helperPath = Join-Path (Split-Path -Parent (Split-Path -Parent $PSScriptRoot)) 'helpers\prefix-input.ps1'
2+
. $helperPath
3+
4+
$tempDir = New-PrefixTempDir
5+
$coreExtension = Get-PrefixHelperExtensionPath 'extend_core'
6+
$packageExtension = Get-PrefixHelperExtensionPath 'extend_package\init'
7+
8+
try {
9+
$programPath = Join-Path $tempDir 'program.pre'
10+
11+
Set-Content -Path $programPath -Encoding Ascii -Value @'
12+
ASSERT(EQ(TST_EXT_GLOBAL(), "core-global"))
13+
ASSERT(EQ(TST_EXT_PACKAGE_INIT(), "package-init"))
14+
'@
15+
16+
$result = Invoke-PrefixWithArguments -Arguments @($coreExtension, $packageExtension, $programPath)
17+
Assert-PrefixSuccess $result
18+
Assert-NoErrorOutput $result
19+
20+
if ($result.Stdout.Length -ne 0) {
21+
$stdout = Format-VisibleText $result.Stdout
22+
throw "Expected no stdout output, got: $stdout"
23+
}
24+
}
25+
finally {
26+
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
27+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
$helperPath = Join-Path (Split-Path -Parent (Split-Path -Parent $PSScriptRoot)) 'helpers\prefix-input.ps1'
2+
. $helperPath
3+
4+
$tempDir = New-PrefixTempDir
5+
$prexPath = Join-Path (Split-Path -Parent $helperPath) 'extend_prex_only.prex'
6+
7+
try {
8+
$programPath = Join-Path $tempDir 'program.pre'
9+
10+
Set-Content -Path $programPath -Encoding Ascii -Value @'
11+
ASSERT(TRUE)
12+
'@
13+
14+
$result = Invoke-PrefixWithArguments -Arguments @($prexPath, $programPath)
15+
if ($result.ExitCode -eq 0) {
16+
$stdout = Format-VisibleText $result.Stdout
17+
$stderr = Format-VisibleText $result.Stderr
18+
throw "Expected the interpreter to reject a .prex CLI extension input`nSTDOUT: $stdout`nSTDERR: $stderr"
19+
}
20+
}
21+
finally {
22+
Remove-Item -Path $tempDir -Recurse -Force -ErrorAction SilentlyContinue
23+
}

0 commit comments

Comments
 (0)