mirror of
https://github.com/vlang/v.git
synced 2025-08-03 17:57:59 -04:00
tests: add more tests for importing @keyword as function names, and for V enums with c++ keyword field names (#23696)
This commit is contained in:
parent
6ed56eef64
commit
4baa6cd70e
@ -0,0 +1,13 @@
|
||||
enum MyEnum {
|
||||
catch
|
||||
class
|
||||
dynamic_cast
|
||||
static_cast
|
||||
operator
|
||||
virtual
|
||||
}
|
||||
|
||||
fn test_cpp_keywords_used_as_enum_values() {
|
||||
e := MyEnum.class
|
||||
assert e.str() == 'class'
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
import mymod { @as, @asm, @assert, @atomic, @break, @const, @continue, @defer, @else, @enum, @false, @fn, @for, @go, @goto, @if, @implements, @import, @in, @interface, @is, @isreftype, @lock, @match, @module, @mut, @or, @pub, @return, @rlock, @select, @shared, @sizeof, @spawn, @static, @struct, @true, @type, @typeof, @union, @unsafe, @volatile }
|
||||
|
||||
fn call_keywords() {
|
||||
@as()
|
||||
@asm()
|
||||
@assert()
|
||||
@atomic()
|
||||
@break()
|
||||
@const()
|
||||
@continue()
|
||||
@defer()
|
||||
@else()
|
||||
@enum()
|
||||
@false()
|
||||
@fn()
|
||||
@for()
|
||||
@go()
|
||||
@goto()
|
||||
@if()
|
||||
@implements()
|
||||
@import()
|
||||
@in()
|
||||
@interface()
|
||||
@is()
|
||||
@isreftype()
|
||||
@lock()
|
||||
@match()
|
||||
@module()
|
||||
@mut()
|
||||
@or()
|
||||
@pub()
|
||||
@return()
|
||||
@rlock()
|
||||
@select()
|
||||
@shared()
|
||||
@sizeof()
|
||||
@spawn()
|
||||
@static()
|
||||
@struct()
|
||||
@true()
|
||||
@type()
|
||||
@typeof()
|
||||
@union()
|
||||
@unsafe()
|
||||
@volatile()
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
call_keywords()
|
||||
assert true
|
||||
}
|
173
vlib/v/tests/project_importing_v_keywords/mymod/f.v
Normal file
173
vlib/v/tests/project_importing_v_keywords/mymod/f.v
Normal file
@ -0,0 +1,173 @@
|
||||
module mymod
|
||||
|
||||
pub fn @as() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @asm() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @assert() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @atomic() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @break() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @const() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @continue() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @defer() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @else() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @enum() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @false() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @fn() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @for() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @go() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @goto() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @if() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @implements() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @import() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @in() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @interface() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @is() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @isreftype() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @lock() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @match() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @module() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @mut() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @none() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @or() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @pub() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @return() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @rlock() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @select() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @shared() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @sizeof() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @spawn() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @static() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @struct() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @true() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @type() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @typeof() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @union() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @unsafe() {
|
||||
println(@LOCATION)
|
||||
}
|
||||
|
||||
pub fn @volatile() {
|
||||
println(@LOCATION)
|
||||
}
|
0
vlib/v/tests/project_importing_v_keywords/v.mod
Normal file
0
vlib/v/tests/project_importing_v_keywords/v.mod
Normal file
Loading…
x
Reference in New Issue
Block a user