-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add DTS workflow and update DTS tests - Add GitHub Actions workflow for DTS testing - Update Makefile to include DTS target - Modify DTS script to run multiple simulations - Fix cursor position calculation in DTS utility test: increase test count to 1 million Increase the number of test iterations from 100k to 1M to improve test coverage and reliability. feat(tests): final fixes and notes around stage 1 dts
- Loading branch information
Showing
7 changed files
with
118 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: DTS | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- "main" | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
nvim-versions: ['nightly'] | ||
os: [ubuntu-latest] | ||
fail-fast: false | ||
name: DTS Tests | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- uses: rhysd/action-setup-vim@v1 | ||
with: | ||
neovim: true | ||
version: ${{ matrix.nvim-versions }} | ||
|
||
- name: run dts | ||
run: make dts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
local M = {} | ||
|
||
local ranges = { | ||
{ 32, 126 }, -- Basic Latin (ASCII) | ||
--TODO: Add other character ranges but this opens a load of multibyte edge cases | ||
-- { 160, 591 }, -- Latin-1 Supplement and Latin Extended-A | ||
-- { 880, 2047 }, -- Greek, Cyrillic, Armenian, Hebrew | ||
-- { 8192, 8303 }, -- General Punctuation | ||
-- { 9728, 9983 }, -- Miscellaneous Symbols | ||
-- { 12352, 12447 }, -- Hiragana | ||
-- { 19904, 19967 }, -- Mahjong Tiles | ||
-- { 0x1F300, 0x1F6FF }, -- Emoji | ||
} | ||
|
||
---@class dts.Random | ||
---@field cursor_col number | ||
---@field line string | ||
|
||
---Generate a random line with Unicode characters. | ||
---@param seed number | ||
---@return dts.Random | ||
function M.generate_random_line(seed) | ||
math.randomseed(seed) -- Set the seed for reproducibility | ||
|
||
-- Randomize the line length (e.g., between 20 and 100 characters) | ||
local line_length = math.random(20, 100) | ||
|
||
-- Function to generate a random printable Unicode character | ||
local function random_unicode_char() | ||
-- Randomly pick a range | ||
local range = ranges[math.random(1, #ranges)] | ||
-- Generate a random codepoint within the selected range | ||
local codepoint = math.random(range[1], range[2]) | ||
return vim.fn.nr2char(codepoint) -- Convert codepoint to UTF-8 character | ||
end | ||
|
||
-- Generate the random line with Unicode characters | ||
local line = "" | ||
for _ = 1, line_length do | ||
line = line .. random_unicode_char() | ||
end | ||
|
||
-- Choose a random cursor position within the line | ||
local cursor_col = math.random(1, vim.fn.strcharlen(line)) -- Ensure valid cursor position | ||
---@type dts.Random | ||
return { | ||
cursor_col = cursor_col, | ||
line = line, | ||
} | ||
end | ||
|
||
return M |