repo stringclasses 341
values | file_path stringlengths 29 173 | language stringclasses 2
values | file_type stringclasses 4
values | code stringlengths 2 1.66M | tokens int64 2 598k |
|---|---|---|---|---|---|
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lib/typedefs.luau | luau | .luau | local path = require("@std/path")
local process = require("@std/process")
type version = { version: string, versionSuffix: string, versionFull: string }
local version: version = _G["version"]
local TYPEDEFS_VERSION = version.version
local TYPEDEFS_BASE_DIR = `.lute/typedefs/{TYPEDEFS_VERSION}`
local TYPEDEFS_RELATIVE... | 997 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lint/configutils.luau | luau | .luau | local internalTypes = require("./internaltypes")
local function assertTableStructure(tbl: { [unknown]: unknown }, keytype: string, valuetype: string?, err: string)
for k, v in tbl do
assert(typeof(k) == keytype, err)
if valuetype then
assert(typeof(v) == valuetype, err)
end
end
end
local function assertIsA... | 521 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lint/internaltypes.luau | luau | .luau | local types = require("@lint")
local parseIgnores = require("../lib/parseIgnores")
local path = require("@std/path")
local syntax = require("@std/syntax")
export type RuleConfig = {
ignores: { string }?,
severity: types.severity?,
off: true?,
options: types.RuleOptions?,
}
export type LintConfig = {
ignores: { s... | 246 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lint/lintCore.luau | luau | .luau | local configUtils = require("./configutils")
local fs = require("@std/fs")
local internalTypes = require("./internaltypes")
local luau = require("@std/luau")
local parseIgnores = require("../lib/parseIgnores")
local pathLib = require("@std/path")
local process = require("@std/process")
local syntax = require("@std/synt... | 3,910 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lint/lsp/init.luau | luau | .luau | local lintTypes = require("@lint")
local lspTypes = require("@self/types")
local pathLib = require("@std/path")
local syntax = require("@std/syntax")
local tableext = require("@std/tableext")
local lsp = {}
local function severity(sev: lintTypes.severity): number
if sev == "error" then
return 1
elseif sev == "war... | 565 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lint/lsp/types.luau | luau | .luau | export type Diagnostic = {
read range: Range, -- zero-based
read severity: number, -- 1: Error, 2: Warning, 3: Information, 4: Hint
read code: string, -- lint name
read codeDescription: string?, -- optional property to describe the violation
read source: "lute lint",
read message: string,
read tags: { number }?,... | 219 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lint/printer.luau | luau | .luau | local fs = require("@std/fs")
local path = require("@std/path")
local stringext = require("@std/stringext")
local types = require("@lint")
local printerLib = {}
local TAB_SIZE = 4
local function formatLint(lint: types.LintViolation, sourceLines: { string }): string
local lines = {}
table.insert(lines, `{lint.seve... | 1,049 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lint/rules/almost_swapped.luau | luau | .luau | local lintTypes = require("@lint")
local path = require("@std/path")
local query = require("@std/syntax/query")
local stringext = require("@std/stringext")
local syntax = require("@std/syntax")
local printer = require("@std/syntax/printer")
local utils = require("@std/syntax/utils")
local name = "almost_swapped"
local... | 1,011 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lint/rules/constant_table_comparison.luau | luau | .luau | local lintTypes = require("@lint")
local path = require("@std/path")
local query = require("@std/syntax/query")
local stringext = require("@std/stringext")
local syntax = require("@std/syntax")
local syntaxPrinter = require("@std/syntax/printer")
local utils = require("@std/syntax/utils")
local name = "constant_table_... | 602 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lint/rules/divide_by_zero.luau | luau | .luau | local lintTypes = require("@lint")
local path = require("@std/path")
local query = require("@std/syntax/query")
local syntax = require("@std/syntax")
local utils = require("@std/syntax/utils")
local name = "divide_by_zero"
local message = "Dividing by zero will always result in NaN, consider using `math.nan` instead."... | 536 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lint/rules/duplicate_keys.luau | luau | .luau | local lintTypes = require("@lint")
local path = require("@std/path")
local query = require("@std/syntax/query")
local syntax = require("@std/syntax")
local utils = require("@std/syntax/utils")
local name = "duplicate_keys"
local message = "Duplicate keys in table literals will result in only the last one being include... | 541 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lint/rules/global_function_in_scope.luau | luau | .luau | local lintTypes = require("@lint")
local path = require("@std/path")
local syntax = require("@std/syntax")
local visitorLib = require("@std/syntax/visitor")
local name = "global_function_in_scope"
local message =
"Non-local function declaration found inside a nested scope. Use 'local function' instead, or move this t... | 377 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lint/rules/no_any.luau | luau | .luau | local lintTypes = require("@lint")
local path = require("@std/path")
local query = require("@std/syntax/query")
local syntax = require("@std/syntax")
local utils = require("@std/syntax/utils")
local name = "no_any"
local message =
"Consider using `unknown` instead of `any` as a type-safe alternative that requires nar... | 282 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lint/rules/parenthesized_conditions.luau | luau | .luau | local lintTypes = require("@lint")
local path = require("@std/path")
local query = require("@std/syntax/query")
local syntax = require("@std/syntax")
local syntaxPrinter = require("@std/syntax/printer")
local name = "parenthesized_conditions"
local message = "Luau doesn't require parentheses around conditions. You can... | 683 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/lint/rules/reassigned_parameter.luau | luau | .luau | local lintTypes = require("@lint")
local path = require("@std/path")
local syntax = require("@std/syntax")
local visitorLib = require("@std/syntax/visitor")
local name = "reassigned_parameter"
local message = "Did you mean to reassign to a function parameter?"
local target = "https://lute.luau.org/cli/lint/reassigned_... | 522 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/new/init.luau | luau | .luau | local cli = require("@batteries/cli")
local fs = require("@std/fs")
local path = require("@std/path")
local process = require("@std/process")
local typedefs = require("./lib/typedefs")
local USAGE = "Usage: lute new <project-name>"
local function printHelp()
print(USAGE)
print([[
Create a new Lute project with a st... | 577 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/pkg/init.luau | luau | .luau | local process = require("@std/process")
local install = require("@self/loom-core/src/commands/install")
local authenticate = require("@self/loom-core/src/commands/authenticate")
local USAGE = "Usage: lute pkg <command>"
local function printHelp()
print(USAGE)
print([[
Loom package manager for Luau projects.
COMM... | 257 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/pkg/loom-core/extern/unzip/crc.luau | luau | .luau | local CRC32_TABLE: { number } = table.create(256) :: any
-- TODO: Maybe compute this AoT as an optimization
-- Initialize the lookup table and lock it in place
for i = 0, 255 do
local crc = i
for _ = 1, 8 do
if bit32.band(crc, 1) == 1 then
crc = bit32.bxor(bit32.rshift(crc, 1), 0xEDB88320)
else
crc = bit32... | 741 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/pkg/loom-core/extern/unzip/inflate.luau | luau | .luau | -- Tree class for storing Huffman trees used in DEFLATE decompression
local Tree = {}
export type Tree = typeof(setmetatable({} :: TreeInner, { __index = Tree }))
type TreeInner = {
table: { number }, -- Length of 16, stores code length counts
trans: { number }, -- Length of 288, stores code to symbol translations
... | 5,268 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/pkg/loom-core/extern/unzip/utils/path.luau | luau | .luau | --- Canonicalize a path by removing redundant components
local function canonicalize(path: string): string
-- We convert any `\\` separators to `/` separators to ensure consistency
local components = string.split(path:gsub("\\", "/"), "/")
local result = {}
for _, component in components do
if component == "." th... | 827 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/pkg/loom-core/extern/unzip/utils/validate_crc.luau | luau | .luau | local crc32 = require("../crc")
export type CrcValidationOptions = {
skip: boolean,
expected: number,
}
local function validateCrc(decompressed: buffer, validation: CrcValidationOptions)
-- Unless skipping validation is requested, we verify the checksum
if not validation.skip then
local computed = crc32(decompr... | 136 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/pkg/loom-core/src/authenticationstore.luau | luau | .luau | local fs = require("@std/fs")
local luau = require("@std/luau")
local path = require("@std/path")
local process = require("@std/process")
local pp = require("@batteries/pp")
export type AuthenticationEntry = {
read token: string,
}
export type AuthenticationStore = {
[string]: AuthenticationEntry,
}
local function... | 291 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/pkg/loom-core/src/commands/install.luau | luau | .luau | local cli = require("@batteries/cli")
local fs = require("@std/fs")
local lockfile = require("../lockfile")
local manifest = require("../manifest")
local resolution = require("../resolution")
local path = require("@std/path")
local process = require("@std/process")
local function printDiagnostics(lock: lockfile.Lockfi... | 585 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/pkg/loom-core/src/credentials.luau | luau | .luau | local fs = require("@std/fs")
local luau = require("@std/luau")
local path = require("@std/path")
local process = require("@std/process")
local stringext = require("@std/stringext")
export type CredentialRequest = {
read protocol: string,
read host: string,
read path: string?,
}
export type CredentialProvider = {
... | 1,002 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/pkg/loom-core/src/semver/init.luau | luau | .luau | --!strict
local parser = require("@self/parser")
local solver = require("@self/solver")
export type PrereleaseId = parser.PrereleaseId
export type Version = parser.Version
export type Comparator = parser.Comparator
export type Constraint = parser.Constraint
export type PackageVersion = solver.PackageVersion
export t... | 148 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/pkg/loom-core/src/semver/parser.luau | luau | .luau | --!strict
export type PrereleaseId = string | number
export type Version = {
read major: number,
read minor: number,
read patch: number,
read prerelease: { PrereleaseId },
read build: { string },
}
export type Comparator = {
read op: "=" | ">" | ">=" | "<" | "<=",
read version: Version,
}
-- A constraint is ... | 4,029 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/pkg/loom-core/src/semver/solver.luau | luau | .luau | --!strict
local tableext = require("@std/tableext")
local parser = require("./parser")
export type PackageVersion = {
read name: string,
read version: parser.Version,
read versionString: string,
read dependencies: { [string]: Requirement },
}
export type Requirement = {
read name: string,
read constraint: par... | 2,243 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/pkg/loom-core/src/store.luau | luau | .luau | local fs = require("@std/fs")
local path = require("@std/path")
local process = require("@std/process")
local STORE_PATH_PREFIX = "@pkg/"
local function getStoreDirectory(): string
return path.format(path.join(process.homedir(), ".loom", "store"))
end
local function getPackagePath(key: string): string
return path.... | 227 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/self/binary.luau | luau | .luau | local fs = require("@std/fs")
local process = require("@std/process")
local system = require("@std/system")
local function swapBinary(destination: string, new: string): ()
local backup = `{destination}.old`
pcall(fs.remove, backup)
do
local ok, err = pcall(fs.move, destination, backup)
if not ok then
pcall(... | 396 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/self/init.luau | luau | .luau | local process = require("@std/process")
local install = require("@self/install")
local uninstall = require("@self/uninstall")
local update = require("@self/update")
local HELP_STRING = [[Usage: lute self <command> [options]
Manage the host lute installation in ~/.lute.
COMMANDS:
install Install the running l... | 268 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/self/install.luau | luau | .luau | local cli = require("@batteries/cli")
local fs = require("@std/fs")
local io = require("@std/io")
local path = require("@std/path")
local process = require("@std/process")
local stringext = require("@std/stringext")
local paths = require("./paths")
local pathenv = require("./pathenv")
local HELP_STRING = [[
Install t... | 491 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/self/pathenv.luau | luau | .luau | local fs = require("@std/fs")
local path = require("@std/path")
local process = require("@std/process")
local system = require("@std/system")
local paths = require("./paths")
local BLOCK_BEGIN = "# >>> lute self install >>>"
local BLOCK_END = "# <<< lute self install <<<"
local PATH_EXPORT = 'export PATH="$HOME/.lute... | 1,052 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/self/paths.luau | luau | .luau | local path = require("@std/path")
local process = require("@std/process")
local system = require("@std/system")
local function lutePath(): string
return path.format(path.join(process.homedir(), ".lute"))
end
local function binPath(): string
return path.format(path.join(lutePath(), "bin"))
end
local function exeNam... | 148 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/self/uninstall.luau | luau | .luau | local cli = require("@batteries/cli")
local fs = require("@std/fs")
local io = require("@std/io")
local path = require("@std/path")
local process = require("@std/process")
local stringext = require("@std/stringext")
local system = require("@std/system")
local paths = require("./paths")
local pathenv = require("./pathe... | 513 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/self/update.luau | luau | .luau | local cli = require("@batteries/cli")
local fs = require("@std/fs")
local path = require("@std/path")
local process = require("@std/process")
local system = require("@std/system")
local binary = require("./binary")
local paths = require("./paths")
local release = require("./release")
local REPO = "luau-lang/lute"
lo... | 675 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/setup/init.luau | luau | .luau | local cli = require("@batteries/cli")
local definitions = require("@self/generated/definitions")
local fs = require("@std/fs")
local path = require("@std/path")
local process = require("@std/process")
local json = require("@std/json")
local typedefs = require("./lib/typedefs")
local BASE_PATH = typedefs.TYPEDEFS_PATH
... | 643 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/cli/commands/transform/printDiffHunks.luau | luau | .luau | --[[
Module to trim the diff of a file into hunks
Better solution is prob to do this at the printdiff level, but I didn't feel like doing all that yet 🫠
]]
local prettydiff = require("@batteries/difftext").prettydiff
local function getDiffType(line: string)
-- Looks for + or -, followed by spaces, numbers, spaces,... | 415 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/commands/lint/types.luau | luau | .luau | local path = require("@std/path")
local syntax = require("@std/syntax")
export type severity = "error" | "warning" | "info" | "hint"
export type tag = "unnecessary" | "deprecated"
export type LintViolation = {
lintname: string,
location: syntax.Span,
message: string,
severity: severity,
sourcepath: path.Path?,
... | 222 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/commands/transform/types.luau | luau | .luau | local syntax = require("@std/syntax")
local syntaxTypes = require("@std/syntax/types")
export type Context<Options = { [any]: any }> = {
path: string,
source: string,
parseresult: syntax.CstParseResult,
options: Options,
}
export type Transformer = (Context) -> string | syntaxTypes.Replacements
export type Confi... | 181 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/fs.luau | luau | .luau | --!strict
-- @std/fs
-- stdlib for `@lute/fs`
-- Provides file system utility functions that handles file paths as path types instead of strings
local deque = require("@batteries/collections/deque")
local fs = require("@lute/fs")
local pathlib = require("@std/path")
local sys = require("@std/system")
local win32paths ... | 2,237 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/luau.luau | luau | .luau | --!strict
-- @std/luau
-- stdlib for `@lute/luau`
-- Provides utilities for parsing and compiling Luau source code
local cst = require("@lute/syntax/cst")
local luteLuau = require("@lute/luau")
local parser = require("@lute/syntax/parser")
local fs = require("@lute/fs")
local path = require("@std/path")
local query =... | 964 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/path/init.luau | luau | .luau | local platform = require("@std/system/platform")
local posix = require("@self/posix")
local win32 = require("@self/win32")
local pathtypes = require("@self/types")
local pathlib = {}
--- A structured, platform-aware file system path.
export type Path = pathtypes.Path
--- Anything that can be used as a path: a strin... | 765 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/path/pathinterface.luau | luau | .luau | export type PathInterface = {
__tostring: (self: PathInterface) -> string,
}
return table.freeze({})
| 25 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/path/posix/init.luau | luau | .luau | local process = require("@lute/process")
local posixtypes = require("@self/types")
local pathinterface = require("./pathinterface")
export type Path = posixtypes.Path
export type Pathlike = posixtypes.Pathlike
local posix = {}
posix.pathmt = {} :: pathinterface.PathInterface
--- Returns the last component of `path`,... | 1,766 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/path/posix/types.luau | luau | .luau | local pathinterface = require("../pathinterface")
--- The raw data of a POSIX path: an array of components and a flag indicating whether the path is absolute.
export type PathData = {
parts: { string },
absolute: boolean,
}
--- A structured POSIX path.
export type Path = setmetatable<PathData, pathinterface.PathInt... | 108 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/path/types.luau | luau | .luau | local posixtypes = require("@std/path/posix/types")
local win32types = require("@std/path/win32/types")
export type Path = posixtypes.Path | win32types.Path
export type Pathlike = posixtypes.Pathlike | win32types.Pathlike
return {}
| 56 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/path/win32/init.luau | luau | .luau | local process = require("@lute/process")
local win32types = require("@self/types")
local pathinterface = require("./pathinterface")
export type PathKind = win32types.PathKind
export type Path = win32types.Path
export type Pathlike = win32types.Pathlike
local win32 = {}
win32.pathmt = {} :: pathinterface.PathInterface... | 2,488 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/path/win32/types.luau | luau | .luau | local pathinterface = require("../pathinterface")
--- Describes how a Windows path is rooted:
--- - `"absolute"`: Drive-rooted path, e.g. `C:\foo`.
--- - `"unc"`: UNC path, e.g. `\\server\share`.
--- - `"relative"`: A path with no drive or UNC root.
export type PathKind = "unc" | "absolute" | "relative"
--- The raw d... | 193 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/process.luau | luau | .luau | --!strict
-- @std/process
-- stdlib for `@lute/process`
-- Provides process-related utility functions that handles file paths as path types instead of strings
local process = require("@lute/process")
local pathlib = require("@std/path")
local processlib = {}
--- How a child process's standard streams should be handl... | 773 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/syntax/parser.luau | luau | .luau | --!strict
-- @std/syntax/parser
-- Parser for Luau source code into Luau CST nodes
local luteParser = require("@lute/syntax/parser")
local types = require("./types")
local parser = {}
--- Parses Luau source code into a CstStatBlock
function parser.parseBlock(source: string): types.CstStatBlock
return luteParser.par... | 185 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/syntax/query.luau | luau | .luau | --!strict
-- @std/syntax/query
-- Provides utility functions for querying Luau CST nodes
local tableext = require("@std/tableext")
local types = require("./types")
local visitor = require("./visitor")
type Node = types.CstNode
--- A collection of CST nodes that supports chained filtering, mapping, and replacement op... | 1,393 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/syntax/utils/init.luau | luau | .luau | local types = require("./types")
local utils = {}
--- Returns `n` narrowed to `CstLocal` if it is a local variable node, or `nil` otherwise.
function utils.isLocal(n: types.CstNode): types.CstLocal?
return if n.kind == "local" then n else nil
end
--- Returns `n` narrowed to `CstExprGroup` if it is a parenthesized e... | 4,491 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/syntax/utils/trivia.luau | luau | .luau | local query = require("../query")
local types = require("../types")
local retrieverLib = {}
--- Returns the leading trivia of the leftmost token in `n`, or an empty array if there are no tokens.
function retrieverLib.leftmostTrivia(n: types.CstNode): { types.Trivia }
local q = query.findAllFromRoot<<types.CstToken>>... | 428 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/system/init.luau | luau | .luau | --!strict
-- @std/system
-- stdlib for `@lute/system`
-- Provides re-exports of `@lute/system` and boolean properties for OS detection
local system = require("@lute/system")
local path = require("@std/path")
local platform = require("@self/platform")
local systemlib = {}
--- Returns the path of the system's temporar... | 216 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/system/platform.luau | luau | .luau | local system = require("@lute/system")
local osName = string.lower(system.os)
local win32 = osName == "windows_nt"
local linux = osName == "linux"
local macos = osName == "darwin"
local unix = macos or linux or osName == "unix" or osName == "posix"
return table.freeze({ win32 = win32, linux = linux, macos = macos, u... | 93 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/tableext.luau | luau | .luau | --!strict
-- @std/tableext
-- stdlib for an extension of the built-in table library in Luau
-- Provides additional utility functions for table operations
local tableext = {}
-- Functions on general tables
--- Returns a new table with the same keys as `table`, where each value has been transformed by applying `f` to ... | 1,525 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/task.luau | luau | .luau | --!strict
-- @std/task
-- stdlib for `@lute/task`
-- Provides utilities for creating and managing asynchronous tasks
local lutetask = require("@lute/task")
local task = {}
--- Schedules `routine` to run immediately on the next resumption cycle, passing any additional arguments to it. Returns the thread.
function tas... | 321 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/time/duration.luau | luau | .luau | --!strict
-- Submodule of @std/time that provides utility functions for time durations
local time = require("@lute/time")
--- A span of time.
export type Duration = time.Duration
local duration = {}
--- Creates a `Duration` from a number of `seconds` and an additional number of nanoseconds, `subsecnanos`.
function ... | 357 |
luau-lang/lute | luau-lang-lute-7dab7df/lute/std/libs/time/init.luau | luau | .luau | --!strict
-- @std/time
-- Provides utility functions for time
local luteTime = require("@lute/time")
local duration = require("@self/duration")
local time = {}
--- A span of time.
export type Duration = duration.Duration
--- An opaque point in time, used with `time.since` to measure elapsed time.
export type Instant... | 151 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/batteries/base64.test.luau | luau | .luau | local test = require("@std/test")
local base64 = require("@batteries/base64")
local function enc(s: string): string
return buffer.tostring(base64.encode(buffer.fromstring(s)))
end
local function dec(s: string): string
return buffer.tostring(base64.decode(buffer.fromstring(s)))
end
-- RFC 4648 test vectors
local tes... | 543 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/batteries/cli.test.luau | luau | .luau | local test = require("@std/test")
local cli = require("@batteries/cli")
test.suite("CLI flags", function(suite)
suite:case("longFlag", function(assert)
local p = cli.parser()
p:add("verbose", "flag", {})
p:parse({ "--verbose" })
assert.that(p:has("verbose"))
end)
suite:case("shortFlag", function(assert)
... | 2,284 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/batteries/cli/snapshots/help_no_alias_when_absent.snap.luau | luau | .luau | local cli = require("@batteries/cli")
local p = cli.parser()
p:add("verbose", "flag", { help = "Enable verbose output" })
p:help()
| 37 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/batteries/cli/snapshots/help_shows_alias.snap.luau | luau | .luau | local cli = require("@batteries/cli")
local p = cli.parser()
p:add("verbose", "flag", { aliases = { "v" }, help = "Enable verbose output" })
p:help()
| 44 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/batteries/cli/snapshots/help_shows_multiple_aliases.snap.luau | luau | .luau | local cli = require("@batteries/cli")
local p = cli.parser()
p:add("verbose", "flag", { aliases = { "v", "V" }, help = "Enable verbose output" })
p:help()
| 47 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/batteries/collections/deque.test.luau | luau | .luau | local deque = require("@batteries/collections/deque")
local test = require("@std/test")
test.suite("Deque", function(suite)
suite:case("dequeNewWithNoValueCreatesEmptyDeque", function(assert)
local deq = deque.new()
assert.eq(deq:peekfront(), nil)
assert.eq(deq:peekback(), nil)
assert.eq(#deq, 0)
end)
suit... | 774 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/batteries/difftext.test.luau | luau | .luau | local difftext = require("@batteries/difftext")
local richterm = require("@batteries/richterm")
local test = require("@std/test")
local diff = difftext.diff
-- Each diff operation has structure: { key: "EQUAL" | "ADD" | "DELETE", text: string }
-- Order matters - the sequence of operations defines the transformation
... | 5,312 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/batteries/glob.test.luau | luau | .luau | local fs = require("@std/fs")
local glob = require("@batteries/glob")
local path = require("@std/path")
local system = require("@std/system")
local test = require("@std/test")
type Folder = { [string]: Hierarchy }
type Hierarchy = "file" | Folder
local root = path.format(path.join(system.tmpdir(), "test-glob-hierarch... | 2,249 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/batteries/toml-test.test.luau | luau | .luau | -- Tests the toml battery against the official toml-test suite.
-- Must be run from the repo root (where extern/toml-test/tests/ lives).
--
-- Valid tests: each .toml file is parsed and compared against its .json
-- counterpart using the toml-test tagged-value format.
-- Invalid tests: each .toml file must cause toml.d... | 1,684 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/batteries/toml.test.luau | luau | .luau | local test = require("@std/test")
local toml = require("@batteries/toml")
test.suite("TOML deserialization", function(suite)
suite:case("simpleKeyValue", function(assert)
local result: any = toml.deserialize('name = "hello"\ncount = 42\nenabled = true\n')
assert.eq(result.name, "hello")
assert.eq(result.count, ... | 761 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/check.test.luau | luau | .luau | local path = require("@std/path")
local process = require("@std/process")
local test = require("@std/test")
local lutePath = path.format(process.execPath())
test.suite("LuteTypeCheck", function(suite)
suite:case("usesNewSolver", function(assert)
local testFilePath = path.format(path.join("tests", "src", "staticreq... | 114 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/compile.test.luau | luau | .luau | local fs = require("@std/fs")
local process = require("@std/process")
local path = require("@std/path")
local system = require("@std/system")
local test = require("@std/test")
local testutil = require("../testutil")
local COMPILER_CONTENTS = [[
local luau = require("@lute/luau")
local fs = require("@std/fs")
local ar... | 401 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/discovery/smoke.test.luau | luau | .luau | local test = require("@std/test")
test.suite("SmokeSuite", function(suite)
suite:case("makeFail", function(assert)
-- assert.eq(1, 2)
assert.eq(1, 1) -- comment this and uncomment above to make the test fail
end)
suite:case("makePass", function(assert)
assert.eq(1, 1)
end)
end)
test.case("passing", function... | 95 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/lib/files.test.luau | luau | .luau | local files = require("@commands/lib/files")
local fs = require("@std/fs")
local path = require("@std/path")
local system = require("@std/system")
local test = require("@std/test")
local tmpdir = system.tmpdir()
local testPath = path.join(tmpdir, "gitignore_test")
test.suite("CliLibFiles", function(suite)
suite:befo... | 2,287 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/lint/snapshots/duplicate_keys_general_number.snap.luau | luau | .luau | local t = { [1] = 1, [1] = 2 }
| 18 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/lint/snapshots/duplicate_keys_general_string.snap.luau | luau | .luau | local t = { ["a"] = 1, ["a"] = 2 }
| 18 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/lint/snapshots/duplicate_keys_list.snap.luau | luau | .luau | local t = { 1, 2, [2] = 3 }
| 17 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/lint/snapshots/duplicate_keys_no_warn_general_zero.snap.luau | luau | .luau | local t = { [0] = 1 }
| 11 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/lint/snapshots/duplicate_keys_record.snap.luau | luau | .luau | local t = { a = 1, a = 2 }
| 14 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/lint/snapshots/duplicate_keys_string_and_record.snap.luau | luau | .luau | local t = { ["a"] = 1, a = 2 }
| 16 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/lint/snapshots/lint.config.luau | luau | .luau | return {
lute = {
lint = {
ignores = {}, -- explicitly ignore nothing
},
},
}
| 28 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/lint/snapshots/output_flag_to_file.snap.luau | luau | .luau | local x = 1 / 0
| 9 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/lint/snapshots/snap.config.luau | luau | .luau | return {
default = {
args = {
"lint",
"--no-default-lints",
"-c",
"tests/cli/lint/snapshots/lint.config.luau",
"-r",
"lute/cli/commands/lint/rules/duplicate_keys.luau",
},
-- lint exits with code 1 when warnings are found; use expectedExitCode = 0 for no-warning cases
expectedExitCode = 1,
}... | 228 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/loadmodule.test.luau | luau | .luau | local fs = require("@std/fs")
local process = require("@std/process")
local path = require("@std/path")
local system = require("@std/system")
local test = require("@std/test")
local testutil = require("../testutil")
local REQUIRER_CONTENTS = [[
local args = { ... }
assert(#args == 2, "Expected one argument: path to Lu... | 448 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/pkg/fixtures/credentials/invalid-module/credentials/bad.luau | luau | .luau | return {
resolve = function()
return "bad-token"
end,
}
| 15 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/pkg/fixtures/credentials/invalid-providers-type/.config.luau | luau | .luau | return {
lute = {
credentials = {
providers = "./credentials",
},
},
}
| 24 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/pkg/fixtures/credentials/no-match/.config.luau | luau | .luau | return {
lute = {
credentials = {
providers = { "./credentials/other.luau" },
},
},
}
| 30 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/pkg/fixtures/credentials/no-match/credentials/other.luau | luau | .luau | return {
host = "other.example.com",
resolve = function()
return "other-token"
end,
}
| 22 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/pkg/fixtures/resolve_credential.luau | luau | .luau | local credentialProvider = require("@commands/pkg/loom-core/src/credentials")
local protocol, host, repositoryPath, expectedToken = select(2, ...)
local token = credentialProvider.resolveToken(table.freeze({
protocol = protocol,
host = host,
path = repositoryPath,
}))
if expectedToken == "<nil>" then
assert(token... | 100 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/pkg/install.test.luau | luau | .luau | local fs = require("@std/fs")
local path = require("@std/path")
local process = require("@std/process")
local system = require("@std/system")
local test = require("@std/test")
local temporaryDirectory = system.tmpdir()
local workingDirectory = path.join(temporaryDirectory, "lute-pkg")
local lutePath = path.format(proc... | 1,364 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/pkg/resolution.test.luau | luau | .luau | local fs = require("@std/fs")
local path = require("@std/path")
local system = require("@std/system")
local test = require("@std/test")
local resolution = require("@commands/pkg/loom-core/src/resolution")
local parser = require("@commands/pkg/loom-core/src/semver/parser")
local solver = require("@commands/pkg/loom-cor... | 11,673 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/pkg/semver/solver.test.luau | luau | .luau | local test = require("@std/test")
local parser = require("@commands/pkg/loom-core/src/semver/parser")
local solver = require("@commands/pkg/loom-core/src/semver/solver")
local function namedVersion(name: string, vstr: string, deps: { [string]: solver.Requirement }?): solver.PackageVersion
local v = parser.parse(vstr)... | 8,151 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/run.test.luau | luau | .luau | local fs = require("@std/fs")
local pathlib = require("@std/path")
local process = require("@std/process")
local system = require("@std/system")
local test = require("@std/test")
local tmpdir = system.tmpdir()
local rundir = pathlib.join(tmpdir, "lute-run")
local lutePath = pathlib.format(process.execPath())
test.s... | 304 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/self.test.luau | luau | .luau | local fs = require("@std/fs")
local path = require("@std/path")
local process = require("@std/process")
local system = require("@std/system")
local test = require("@std/test")
local release = require("@commands/self/release")
local lutePath = path.format(process.execPath())
local function run(...: string): process.P... | 1,339 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/test.test.luau | luau | .luau | local path = require("@std/path")
local process = require("@std/process")
local test = require("@std/test")
local testutil = require("../testutil")
local lutePath = path.format(process.execPath())
local expected = [[Anonymous:
passing
ExampleSuite:
shouldPass
SmokeSuite:
makeFail
makePass
]]
test.suite("LuteTest... | 698 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/cli/transform.test.luau | luau | .luau | local fs = require("@std/fs")
local path = require("@std/path")
local process = require("@std/process")
local system = require("@std/system")
local test = require("@std/test")
local testutil = require("../testutil")
local TRANSFORMEE_CONTENT = [[
local x = math.sqrt(-1)
local b = x ~= x
]]
local LUAURC_CONTENT = [[
{... | 1,575 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/lute/crypto.test.luau | luau | .luau | local test = require("@std/test")
local crypto = require("@lute/crypto")
test.suite("CryptoRuntimeTests", function(suite)
suite:case("secretboxIsARoundtripStrings", function(assert)
local message = "Remember, remember the Fifth of November."
local box = crypto.secretbox.seal(message)
local opened = crypto.sec... | 892 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/lute/debugger.test.luau | luau | .luau | local test = require("@std/test")
local task = require("@lute/task")
local debug = require("@lute/debugger")
local path = require("@std/path")
local proc = require("@std/process")
local function normalizePath(p: string): string
return (p:gsub("\\", "/"))
end
-- a helper function that basically polls a boolean, sinc... | 3,027 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/lute/task.test.luau | luau | .luau | local test = require("@std/test")
local task = require("@lute/task")
test.suite("LuteTaskSuite", function(suite)
suite:case("simpleTaskWait", function(assert)
local startTime = os.clock()
task.wait(0.5)
local endTime = os.clock()
-- task.wait(0.5) actually waits ~0.48 seconds :)
assert.that(math.ceil(endTi... | 1,062 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/lute/vm.test.luau | luau | .luau | local test = require("@std/test")
local fs = require("@std/fs")
local path = require("@std/path")
local process = require("@std/process")
local system = require("@std/system")
test.suite("LuteVmSuite", function(suite)
suite:case("childVmHasAccessToBuiltins", function(assert)
local tmpdir = system.tmpdir()
local c... | 2,233 |
luau-lang/lute | luau-lang-lute-7dab7df/tests/parserExamples/assignment-1.luau | luau | .luau | x = 1
a, b = 1, true
a, b, c.d.e[f][g][1], h:i().j[k]:l()[m] = true, false, 1, 4
| 48 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.