Update require paths to relative string

This commit is contained in:
aaron 2024-11-13 22:19:20 +00:00
parent 0897821e1f
commit 5abd5eee91
25 changed files with 89 additions and 124 deletions

View file

@ -1,13 +1,12 @@
if not game then script = require "test/relative-string" end local typeof = game and typeof or require "../test/mock".typeof :: never
local typeof = game and typeof or require "test/mock".typeof :: never local Vector2 = game and Vector2 or require "../test/mock".Vector2 :: never
local Vector2 = game and Vector2 or require "test/mock".Vector2 :: never local UDim2 = game and UDim2 or require "../test/mock".UDim2 :: never
local UDim2 = game and UDim2 or require "test/mock".UDim2 :: never
local flags = require(script.Parent.flags) local flags = require "./flags"
local throw = require(script.Parent.throw) local throw = require "./throw"
local bind = require(script.Parent.bind) local bind = require "./bind"
local _, is_action = require(script.Parent.action)() local _, is_action = require "./action"()
local graph = require(script.Parent.graph) local graph = require "./graph"
type Node<T> = graph.Node<T> type Node<T> = graph.Node<T>
type Array<V> = { V } type Array<V> = { V }

View file

@ -1,8 +1,6 @@
if not game then script = require "test/relative-string" end local flags = require "./flags"
local throw = require "./throw"
local flags = require(script.Parent.flags) local graph = require "./graph"
local throw = require(script.Parent.throw)
local graph = require(script.Parent.graph)
local function batch(setter: () -> ()) local function batch(setter: () -> ())
local already_batching = flags.batch local already_batching = flags.batch

View file

@ -1,6 +1,4 @@
if not game then script = require "test/relative-string" end local graph = require "./graph"
local graph = require(script.Parent.graph)
type Node<T> = graph.Node<T> type Node<T> = graph.Node<T>
local create_node = graph.create_node local create_node = graph.create_node
local assert_stable_scope = graph.assert_stable_scope local assert_stable_scope = graph.assert_stable_scope

View file

@ -1,7 +1,5 @@
if not game then script = require "test/relative-string" end local action = require "./action"()
local cleanup = require "./cleanup"
local action = require(script.Parent.action)()
local cleanup = require(script.Parent.cleanup)
local function changed<T>(property: string, callback: (T) -> ()) local function changed<T>(property: string, callback: (T) -> ())
return action(function(instance) return action(function(instance)

View file

@ -1,8 +1,7 @@
if not game then script = require "test/relative-string" end local typeof = game and typeof or require "../test/mock".typeof :: never
local typeof = game and typeof or require "test/mock".typeof :: never
local throw = require(script.Parent.throw) local throw = require "./throw"
local graph = require(script.Parent.graph) local graph = require "./graph"
local get_scope = graph.get_scope local get_scope = graph.get_scope
local push_cleanup = graph.push_cleanup local push_cleanup = graph.push_cleanup

View file

@ -1,7 +1,7 @@
if not game then script = require "test/relative-string" end if not game then script = require "../test/relative-string" end
local throw = require(script.Parent.throw) local throw = require "./throw"
local graph = require(script.Parent.graph) local graph = require "./graph"
type Node<T> = graph.Node<T> type Node<T> = graph.Node<T>
local create_node = graph.create_node local create_node = graph.create_node
local get_scope = graph.get_scope local get_scope = graph.get_scope

View file

@ -1,10 +1,10 @@
if not game then script = require "test/relative-string" end if not game then script = require "../test/relative-string" end
local typeof = game and typeof or require "test/mock".typeof:: never local typeof = game and typeof or require "../test/mock".typeof :: never
local Instance = game and Instance or require "test/mock".Instance :: never local Instance = game and Instance or require "../test/mock".Instance :: never
local throw = require(script.Parent.throw) local throw = require "./throw"
local defaults = require(script.Parent.defaults) local defaults = require "./defaults"
local apply = require(script.Parent.apply) local apply = require "./apply"
local ctor_cache = {} :: { [string]: () -> Instance } local ctor_cache = {} :: { [string]: () -> Instance }

View file

@ -1,6 +1,6 @@
local Enum = game and Enum or require "test/mock".Enum :: never local Enum = game and Enum or require "../test/mock".Enum :: never
local Color3 = game and Color3 or require "test/mock".Color3 :: never local Color3 = game and Color3 or require "../test/mock".Color3 :: never
local Vector3 = game and Vector3 or require "test/mock".Vector3 :: never local Vector3 = game and Vector3 or require "../test/mock".Vector3 :: never
return { return {
Part = { Part = {

View file

@ -1,6 +1,4 @@
if not game then script = require "test/relative-string" end local graph = require "./graph"
local graph = require(script.Parent.graph)
local create_node = graph.create_node local create_node = graph.create_node
local push_child_to_scope = graph.push_child_to_scope local push_child_to_scope = graph.push_child_to_scope
local assert_stable_scope = graph.assert_stable_scope local assert_stable_scope = graph.assert_stable_scope

View file

@ -1,6 +1,4 @@
if not game then script = require "test/relative-string" end local graph = require "./graph"
local graph = require(script.Parent.graph)
local create_node = graph.create_node local create_node = graph.create_node
local assert_stable_scope = graph.assert_stable_scope local assert_stable_scope = graph.assert_stable_scope
local evaluate_node = graph.evaluate_node local evaluate_node = graph.evaluate_node

View file

@ -1,7 +1,5 @@
if not game then script = require "test/relative-string" end local throw = require "./throw"
local flags = require "./flags"
local throw = require(script.Parent.throw)
local flags = require(script.Parent.flags)
export type SourceNode<T> = { export type SourceNode<T> = {
cache: T, cache: T,

View file

@ -4,28 +4,26 @@
local version = { major = 0, minor = 3, patch = 1 } local version = { major = 0, minor = 3, patch = 1 }
if not game then script = require "test/relative-string" end local root = require "./root"
local mount = require "./mount"
local root = require(script.root) local create = require "./create"
local mount = require(script.mount) local apply = require "./apply"
local create = require(script.create) local source = require "./source"
local apply = require(script.apply) local effect = require "./effect"
local source = require(script.source) local derive = require "./derive"
local effect = require(script.effect) local cleanup = require "./cleanup"
local derive = require(script.derive) local untrack = require "./untrack"
local cleanup = require(script.cleanup) local read = require "./read"
local untrack = require(script.untrack) local batch = require "./batch"
local read = require(script.read) local context = require "./context"
local batch = require(script.batch) local switch = require "./switch"
local context = require(script.context) local show = require "./show"
local switch = require(script.switch) local indexes, values = require "./maps"()
local show = require(script.show) local spring, update_springs = require "./spring"()
local indexes, values = require(script.maps)() local action = require "./action"()
local spring, update_springs = require(script.spring)() local changed = require "./changed"
local action = require(script.action)() local throw = require "./throw"
local changed = require(script.changed) local flags = require "./flags"
local throw = require(script.throw)
local flags = require(script.flags)
export type Source<T> = source.Source<T> export type Source<T> = source.Source<T>
export type source<T> = Source<T> export type source<T> = Source<T>

View file

@ -1,8 +1,6 @@
if not game then script = require "test/relative-string" end local throw = require "./throw"
local flags = require "./flags"
local throw = require(script.Parent.throw) local graph = require "./graph"
local flags = require(script.Parent.flags)
local graph = require(script.Parent.graph)
type Node<T> = graph.Node<T> type Node<T> = graph.Node<T>
type SourceNode<T> = graph.SourceNode<T> type SourceNode<T> = graph.SourceNode<T>
local create_node = graph.create_node local create_node = graph.create_node

View file

@ -1,7 +1,5 @@
if not game then script = require "test/relative-string" end local root = require "./root"
local apply = require "./apply"
local root = require(script.Parent.root)
local apply = require(script.Parent.apply)
local function mount<T>(component: () -> T, target: Instance?): () -> () local function mount<T>(component: () -> T, target: Instance?): () -> ()
return root(function() return root(function()

View file

@ -1,5 +1,3 @@
if not game then script = require "test/relative-string" end
local function read<T>(value: T | () -> T): T local function read<T>(value: T | () -> T): T
return if type(value) == "function" then value() else value return if type(value) == "function" then value() else value
end end

View file

@ -1,7 +1,5 @@
if not game then script = require "test/relative-string" end local throw = require "./throw"
local graph = require "./graph"
local throw = require(script.Parent.throw)
local graph = require(script.Parent.graph)
type Node<T> = graph.Node<T> type Node<T> = graph.Node<T>
local create_node = graph.create_node local create_node = graph.create_node
local push_scope = graph.push_scope local push_scope = graph.push_scope

View file

@ -1,6 +1,4 @@
if not game then script = require "test/relative-string" end local switch = require "./switch"
local switch = require(script.Parent.switch)
local function show<T>(source: () -> any, component: () -> T, fallback: (() -> T)?): () -> T? local function show<T>(source: () -> any, component: () -> T, fallback: (() -> T)?): () -> T?
local function truthy() local function truthy()

View file

@ -1,6 +1,4 @@
if not game then script = require "test/relative-string" end local graph = require "./graph"
local graph = require(script.Parent.graph)
type Node<T> = graph.Node<T> type Node<T> = graph.Node<T>
local create_source_node = graph.create_source_node local create_source_node = graph.create_source_node
local push_child_to_scope = graph.push_child_to_scope local push_child_to_scope = graph.push_child_to_scope

View file

@ -1,5 +1,4 @@
if not game then script = require "test/relative-string" end local Vector3 = game and Vector3 or require "../test/mock".Vector3 :: never
local Vector3 = game and Vector3 or require "test/mock".Vector3 :: never
--[[ --[[
@ -21,8 +20,8 @@ Unsupported datatypes:
]] ]]
local throw = require(script.Parent.throw) local throw = require "./throw"
local graph = require(script.Parent.graph) local graph = require "./graph"
type Node<T> = graph.Node<T> type Node<T> = graph.Node<T>
type SourceNode<T> = graph.SourceNode<T> type SourceNode<T> = graph.SourceNode<T>
local create_node = graph.create_node local create_node = graph.create_node

View file

@ -1,7 +1,5 @@
if not game then script = require "test/relative-string" end local throw = require "./throw"
local graph = require "./graph"
local throw = require(script.Parent.throw)
local graph = require(script.Parent.graph)
type Node<T> = graph.Node<T> type Node<T> = graph.Node<T>
type SourceNode<T> = graph.SourceNode<T> type SourceNode<T> = graph.SourceNode<T>
local create_node = graph.create_node local create_node = graph.create_node

View file

@ -1,5 +1,3 @@
if not game then script = require "test/relative-string" end
local function VIDE_ASSERT(msg): any local function VIDE_ASSERT(msg): any
error(msg, 0) error(msg, 0)
end end

View file

@ -1,6 +1,4 @@
if not game then script = require "test/relative-string" end local graph = require "./graph"
local graph = require(script.Parent.graph)
type Node<T> = graph.Node<T> type Node<T> = graph.Node<T>
local get_scope = graph.get_scope local get_scope = graph.get_scope

View file

@ -1,7 +1,7 @@
local testkit = require("test/testkit") local testkit = require("./testkit")
local BENCH, START = testkit.benchmark() local BENCH, START = testkit.benchmark()
local vide = require "src/init" local vide = require "../src/init"
local source = vide.source local source = vide.source
local derive = vide.derive local derive = vide.derive
local effect = vide.effect local effect = vide.effect
@ -200,7 +200,7 @@ end)
TITLE "property apply" TITLE "property apply"
ROOT_BENCH("apply 0 properties", function() ROOT_BENCH("apply 0 properties", function()
local apply = require "src/apply" local apply = require "../src/apply"
local instance = create("Frame") {} local instance = create("Frame") {}
for i = 1, START(N) do for i = 1, START(N) do
@ -209,7 +209,7 @@ ROOT_BENCH("apply 0 properties", function()
end) end)
ROOT_BENCH("apply 8 properties", function() ROOT_BENCH("apply 8 properties", function()
local apply = require "src/apply" local apply = require "../src/apply"
local instance = create("Frame") {} local instance = create("Frame") {}
for i = 1, START(N) do for i = 1, START(N) do
@ -227,7 +227,7 @@ ROOT_BENCH("apply 8 properties", function()
end) end)
ROOT_BENCH("bind property", function() ROOT_BENCH("bind property", function()
local apply = require "src/apply" local apply = require "../src/apply"
local instance = create("Frame") {} local instance = create("Frame") {}
local src = source(1) local src = source(1)
@ -242,7 +242,7 @@ ROOT_BENCH("bind property", function()
end) end)
ROOT_BENCH("update binding", function() ROOT_BENCH("update binding", function()
local apply = require "src/apply" local apply = require "../src/apply"
local instance = create("Frame") {} local instance = create("Frame") {}
local src = source(1) local src = source(1)
@ -512,8 +512,8 @@ do
-- the purpose of the two following benchmarks is to measure the overhead of -- the purpose of the two following benchmarks is to measure the overhead of
-- aggregate construction -- aggregate construction
ROOT_BENCH("set explicit mock vector2", function() ROOT_BENCH("set explicit mock vector2", function()
local apply = require "src/apply" local apply = require "../src/apply"
local Vector2 = require "test/mock".Vector2 local Vector2 = require "../test/mock".Vector2
local label = create "TextLabel" { local label = create "TextLabel" {
AnchorPoint = Vector2.new(1, 1) AnchorPoint = Vector2.new(1, 1)
@ -527,8 +527,8 @@ do
end) end)
ROOT_BENCH("set aggregate mock vector2", function() ROOT_BENCH("set aggregate mock vector2", function()
local apply = require "src/apply" local apply = require "../src/apply"
local Vector2 = require "test/mock".Vector2 local Vector2 = require "../test/mock".Vector2
local label = create "TextLabel" { local label = create "TextLabel" {
AnchorPoint = Vector2.new(1, 1) AnchorPoint = Vector2.new(1, 1)

View file

@ -1,5 +1,5 @@
local vide = require "src/init" local vide = require "../src/init"
local testkit = require("test/testkit") local testkit = require("../test/testkit")
local program_time = os.clock() local program_time = os.clock()

View file

@ -1,12 +1,12 @@
local testkit = require("test/testkit") local testkit = require "./testkit"
local TEST, CASE, CHECK, FINISH = testkit.test() local TEST, CASE, CHECK, FINISH = testkit.test()
local mock = require "test/mock" local mock = require "./mock"
local Instance, Signal = mock.Instance, mock.Signal local Instance, Signal = mock.Instance, mock.Signal
local Vector2, UDim2 = mock.Vector2, mock.UDim2 local Vector2, UDim2 = mock.Vector2, mock.UDim2
local vide = require "src/init" local vide = require "../src/init"
local graph = require "src/graph" local graph = require "../src/graph"
type Node<T> = graph.Node<T> type Node<T> = graph.Node<T>
type Map<K, V> = { [K] : V } type Map<K, V> = { [K] : V }
@ -722,7 +722,7 @@ TEST("create()", wrap_root(function()
local cleanup = vide.cleanup local cleanup = vide.cleanup
do CASE "apply default properties" do CASE "apply default properties"
local defaults = require("src/defaults") local defaults = require "../src/defaults"
local frame = create "Frame" {} :: Instance & { BorderSizePixel: any, BorderColor3: any } local frame = create "Frame" {} :: Instance & { BorderSizePixel: any, BorderColor3: any }
CHECK(frame.BorderSizePixel == defaults.Frame.BorderSizePixel) CHECK(frame.BorderSizePixel == defaults.Frame.BorderSizePixel)
CHECK(frame.BorderColor3 == defaults.Frame.BorderColor3) CHECK(frame.BorderColor3 == defaults.Frame.BorderColor3)
@ -1169,7 +1169,7 @@ TEST("switch()", wrap_root(function()
end end
do CASE "reactive stack resets after error" do CASE "reactive stack resets after error"
local scopes = require "src/graph".scopes local scopes = require "../src/graph".scopes
local input = source(1) local input = source(1)
local n0 = scopes.n local n0 = scopes.n
@ -1328,7 +1328,7 @@ TEST("indexes()", wrap_root(function()
end end
do CASE "reactive stack resets after error" do CASE "reactive stack resets after error"
local scopes = require "src/graph".scopes local scopes = require "../src/graph".scopes
local input = source { 1 } local input = source { 1 }
@ -1507,7 +1507,7 @@ TEST("values()", wrap_root(function()
end end
do CASE "reactive stack resets after error" do CASE "reactive stack resets after error"
local scopes = require "src/graph".scopes local scopes = require "../src/graph".scopes
local input = source { 1 } local input = source { 1 }
@ -2260,7 +2260,7 @@ TEST("context()", function()
end) end)
TEST("nested effects cases", function() TEST("nested effects cases", function()
local vide = require "src/init" local vide = require "../src/init"
local source = vide.source local source = vide.source
local effect = vide.effect local effect = vide.effect
local untrack = vide.untrack local untrack = vide.untrack