Skip to content

Commit

Permalink
Refactor typecheck.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
semyon422 committed Sep 10, 2023
1 parent c02c300 commit 0118eaa
Show file tree
Hide file tree
Showing 14 changed files with 872 additions and 816 deletions.
15 changes: 9 additions & 6 deletions tests/typecheck_test.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
local typecheck = require("typecheck")
local lexer = require("typecheck.lexer")
local class = require("class")
local TypeDecorator = require("typecheck.TypeDecorator")
local ClassDecorator = require("typecheck.ClassDecorator")

local test = {}

local function lex(...)
return assert(typecheck.lex(...))
return assert(lexer.lex(...))
end

local function typeof(t, T)
Expand All @@ -20,7 +23,7 @@ local function check_types(...)
end

function test.lex_unknown()
assert(not typecheck.lex("&"))
assert(not lexer.lex("&"))
end

function test.lex_tokens_count()
Expand Down Expand Up @@ -446,7 +449,7 @@ function test.fix_traceback_typecheck()
end

function test.type_decorator_empty()
local td = typecheck.TypeDecorator()
local td = TypeDecorator()

local strict = typecheck.strict
typecheck.strict = false
Expand All @@ -458,7 +461,7 @@ function test.type_decorator_empty()
end

function test.type_decorator_number_number()
local td = typecheck.TypeDecorator()
local td = TypeDecorator()

td:func_begin()
td:process_annotation("---@param a number")
Expand All @@ -469,7 +472,7 @@ function test.type_decorator_number_number()
end

function test.type_decorator_vararg()
local td = typecheck.TypeDecorator()
local td = TypeDecorator()

td:func_begin()
td:process_annotation("---@return any?...")
Expand All @@ -479,7 +482,7 @@ function test.type_decorator_vararg()
end

function test.class_decorator()
local cd = typecheck.ClassDecorator()
local cd = ClassDecorator()

cd:next("---@class mod.MyClass")
local got = cd:next("local MyClass = class()")
Expand Down
Loading

0 comments on commit 0118eaa

Please sign in to comment.