Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tests/inputs-luau-full_moon/const_function.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const function f() end
const function greet(name: string): string
return "Hello, " .. name
end
10 changes: 10 additions & 0 deletions tests/inputs-luau-full_moon/const_variable.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const x = 5
const f = function() end
const t = { a = 1 }
const x: number = 5
const a, b = 1, 2
const x: number, y: string = 1, "hello"
local const = 4
const a, b = returns_two()
const a, b, c = 1, unpack(t)
const a, b = ...
15 changes: 15 additions & 0 deletions tests/inputs-luau-full_moon/types_leading_union_generic.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-- Issue #350: leading | in generic type arguments
type Test = Box<
| string
| number
>

type Test2 = Box<| string | number>

-- Issue #311 comment: leading & in generic type arguments
type Test3 = Generic<& boolean & string>

type Test4 = Map<
& string & number,
| boolean | nil
>
10 changes: 10 additions & 0 deletions tests/inputs-luau-full_moon/types_leading_union_return.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Issue #311 comment: leading | and & in function return types
type UnionReturn = () -> | string | number

type IntersectionReturn = () -> & string & number

type NestedReturn = (string) -> | boolean | nil

-- Also valid in function type annotations
local f: () -> | string | number = nil
local g: (number) -> & string & number = nil
9 changes: 9 additions & 0 deletions tests/snapshots/tests__luau_full_moon@const_function.lua.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
source: tests/tests.rs
expression: "format(&contents, LuaVersion::Luau)"
input_file: tests/inputs-luau-full_moon/const_function.lua
---
const function f() end
const function greet(name: string): string
return "Hello, " .. name
end
15 changes: 15 additions & 0 deletions tests/snapshots/tests__luau_full_moon@const_variable.lua.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
source: tests/tests.rs
expression: "format(&contents, LuaVersion::Luau)"
input_file: tests/inputs-luau-full_moon/const_variable.lua
---
const x = 5
const f = function() end
const t = { a = 1 }
const x: number = 5
const a, b = 1, 2
const x: number, y: string = 1, "hello"
local const = 4
const a, b = returns_two()
const a, b, c = 1, unpack(t)
const a, b = ...
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
source: tests/tests.rs
expression: "format(&contents, LuaVersion::Luau)"
input_file: tests/inputs-luau-full_moon/types_leading_union_generic.lua
---
-- Issue #350: leading | in generic type arguments
type Test = Box<| string | number>

type Test2 = Box<| string | number>

-- Issue #311 comment: leading & in generic type arguments
type Test3 = Generic<& boolean & string>

type Test4 = Map<& string & number, | boolean | nil>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
source: tests/tests.rs
expression: "format(&contents, LuaVersion::Luau)"
input_file: tests/inputs-luau-full_moon/types_leading_union_return.lua
---
-- Issue #311 comment: leading | and & in function return types
type UnionReturn = () -> | string | number

type IntersectionReturn = () -> & string & number

type NestedReturn = (string) -> | boolean | nil

-- Also valid in function type annotations
local f: () -> | string | number = nil
local g: (number) -> & string & number = nil
Loading