Tests for label shorthands

pull/844/head
Giacomo Cavalieri 2024-07-25 15:48:57 +07:00
parent f8a6614480
commit 9a66875ae1
No known key found for this signature in database
GPG Key ID: 4A196008E732F17E
7 changed files with 117 additions and 7 deletions

@ -444,3 +444,22 @@ const a = -100.001e-1_230
(constant
(identifier)
(float)))
================================================================================
Constant with shorthand labels
================================================================================
const b = Wibble(arg:, arg:)
--------------------------------------------------------------------------------
(source_file
(constant
(identifier)
(record
(constructor_name)
(arguments
(argument
(label))
(argument
(label))))))

@ -247,3 +247,26 @@ pub opaque type Animal(name, cuteness) {
label: (label)
value: (type
name: (type_identifier))))))))
================================================================================
Record update with shorthand labels
================================================================================
Wibble(..wibble, arg:, arg:, arg: todo as "no shorthand")
--------------------------------------------------------------------------------
(source_file
(record_update
(constructor_name)
(identifier)
(record_update_arguments
(record_update_argument
(label))
(record_update_argument
(label))
(record_update_argument
(label)
(todo
(string
(quoted_content)))))))

@ -48,3 +48,31 @@ pub fn main() {
(argument
(string
(quoted_content)))))))))))
================================================================================
Pattern with label shorthand
================================================================================
pub fn main() {
let Wibble(arg1:, arg2:) = todo as "a"
}
--------------------------------------------------------------------------------
(source_file
(function
(visibility_modifier)
(identifier)
(function_parameters)
(function_body
(let
(record_pattern
(constructor_name)
(record_pattern_arguments
(record_pattern_argument
(label))
(record_pattern_argument
(label))))
(todo
(string
(quoted_content)))))))

@ -1070,3 +1070,20 @@ io.println("// hello world!\n")
value: (string
(quoted_content)
(escape_sequence))))))
================================================================================
Call with label shorthand
================================================================================
wibble(arg1:, arg2:)
--------------------------------------------------------------------------------
(source_file
(function_call
(identifier)
(arguments
(argument
(label))
(argument
(label)))))

@ -2,8 +2,8 @@ fn case_case(x: Option(String)) {
// ^ variable.parameter
// ^ type
case #(x, x) {
// ^ variable.parameter
// ^ variable.parameter
// ^ variable.parameter
// ^ variable.parameter
#(None, None) -> None
// ^ constructor
// ^ constructor
@ -22,3 +22,11 @@ fn case_case(x: Option(String)) {
z.foo()
// <- module
}
fn shorthand_label_pattern_arg() {
case todo {
Wibble(arg1:, arg2:) -> todo
// ^ property
// ^ property
}
}

@ -114,3 +114,10 @@ fn let_assert_test() {
// <- keyword
// ^ keyword
}
fn punned_call_arg_test() {
wibble(arg:, arg2:)
// ^ function
// ^ property
// ^ property
}

@ -13,8 +13,16 @@ pub fn new(name: String) {
// ^ variable.parameter
}
let config = Config()
config.connection.host
// ^ variable
// ^ property
// ^ property
pub fn access() {
let config = Config()
config.connection.host
// ^ variable
// ^ property
// ^ property
}
pub fn record_update_shorthand_label() {
User(..user, name:)
// ^ constructor
// ^ property
}