-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker,pref: fix
$if wasm32_emscripten {
check, add tests (vlang#2…
- Loading branch information
Showing
12 changed files
with
150 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module platform_wrapper | ||
|
||
pub fn abc() int { | ||
return 987654321 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module platform_wrapper | ||
|
||
pub fn abc() int { | ||
return 987654321 | ||
} | ||
|
||
pub fn fn_defined_on_linux() int { | ||
// println('hi from ${@FN}, in file_linux.c.v') | ||
return 456 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module platform_wrapper | ||
|
||
pub fn abc() int { | ||
return 987654321 | ||
} | ||
|
||
pub fn fn_defined_on_macos() int { | ||
// println('hi from ${@FN}, in file_macos.c.v') | ||
return 789 | ||
} |
10 changes: 10 additions & 0 deletions
10
vlib/v/gen/c/testdata/platform_wrapper/file_wasm32_emscripten.c.v
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module platform_wrapper | ||
|
||
pub fn abc() int { | ||
return 987654321 | ||
} | ||
|
||
pub fn fn_defined_in_wasm32_emscripten() int { | ||
println('hi from ${@FN}, defined in file_wasm32_emscripten.c.v') | ||
return 12345 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module platform_wrapper | ||
|
||
pub fn abc() int { | ||
return 987654321 | ||
} | ||
|
||
pub fn fn_defined_on_windows() int { | ||
// println('hi from ${@FN}, in file_windows.c.v') | ||
return 123 | ||
} |
9 changes: 9 additions & 0 deletions
9
vlib/v/gen/c/testdata/platform_wrapper_emscripten.c.must_have
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#if defined(CUSTOM_DEFINE_emscripten) | ||
println(_SLIT("> inside then branch of if emscripten")); | ||
|
||
#if defined(__EMSCRIPTEN__) | ||
println(_SLIT("> inside then branch of if wasm32_emscripten")); | ||
|
||
v__gen__c__testdata__platform_wrapper__fn_defined_in_wasm32_emscripten(); | ||
|
||
v__gen__c__testdata__platform_wrapper__abc(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module main | ||
|
||
// vtest vflags: -os wasm32_emscripten | ||
|
||
import platform_wrapper | ||
|
||
fn main() { | ||
println('start') | ||
$if windows { | ||
assert platform_wrapper.fn_defined_on_windows() == 123 | ||
} | ||
$if linux { | ||
assert platform_wrapper.fn_defined_on_linux() == 456 | ||
} | ||
$if macos { | ||
assert platform_wrapper.fn_defined_on_macos() == 789 | ||
} | ||
println('--- 1') | ||
$if emscripten ? { | ||
println('> inside then branch of if emscripten') | ||
assert platform_wrapper.fn_defined_in_wasm32_emscripten() == 12345 | ||
} $else { | ||
println('> inside else branch of if emscripten') | ||
} | ||
println('--- 2') | ||
$if wasm32_emscripten { | ||
println('> inside then branch of if wasm32_emscripten') | ||
assert platform_wrapper.fn_defined_in_wasm32_emscripten() == 12345 | ||
} $else { | ||
println('> inside else branch of if wasm32_emscripten') | ||
} | ||
println('--- 3') | ||
platform_wrapper.abc() | ||
println('done') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
start | ||
--- 1 | ||
> inside else branch of if emscripten | ||
--- 2 | ||
> inside else branch of if wasm32_emscripten | ||
--- 3 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module main | ||
|
||
import platform_wrapper | ||
|
||
fn main() { | ||
println('start') | ||
$if windows { | ||
assert platform_wrapper.fn_defined_on_windows() == 123 | ||
} | ||
$if linux { | ||
assert platform_wrapper.fn_defined_on_linux() == 456 | ||
} | ||
$if macos { | ||
assert platform_wrapper.fn_defined_on_macos() == 789 | ||
} | ||
println('--- 1') | ||
$if emscripten ? { | ||
println('> inside then branch of if emscripten') | ||
assert platform_wrapper.fn_defined_in_wasm32_emscripten() == 12345 | ||
} $else { | ||
println('> inside else branch of if emscripten') | ||
} | ||
println('--- 2') | ||
$if wasm32_emscripten { | ||
println('> inside then branch of if wasm32_emscripten') | ||
assert platform_wrapper.fn_defined_in_wasm32_emscripten() == 12345 | ||
} $else { | ||
println('> inside else branch of if wasm32_emscripten') | ||
} | ||
println('--- 3') | ||
platform_wrapper.abc() | ||
println('done') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters