Skip to content
Open
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
1 change: 0 additions & 1 deletion src/eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export default [
{
rules: {
// TODO: These should be fixed and the rules re-enabled.
"no-regex-spaces": "off",
"no-useless-escape": "off",
"no-empty": "off",
"prefer-const": "off",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,46 +44,46 @@ describe("parseSourceCodeDefinitionsForFile with Elixir", () => {
})

it("should parse function definitions", () => {
expect(parseResult).toMatch(/\d+--\d+ \| def test_function_definition/)
expect(parseResult).toMatch(/\d+--\d+ \| def test_pipeline_definition/)
expect(parseResult).toMatch(/\d+--\d+ \| def test_comprehension_definition/)
expect(parseResult).toMatch(/\d+--\d+ \| def test_sigil_definition/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}def test_function_definition/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}def test_pipeline_definition/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}def test_comprehension_definition/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}def test_sigil_definition/)
debugLog("Function definitions found:", parseResult.match(/def[\s\S]*?end/g))
})

it("should parse macro definitions", () => {
expect(parseResult).toMatch(/\d+--\d+ \| defmacro test_macro_definition/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}defmacro test_macro_definition/)
debugLog("Macro definitions found:", parseResult.match(/defmacro[\s\S]*?end/g))
})

it("should parse protocol implementations", () => {
expect(parseResult).toMatch(/\d+--\d+ \| defimpl String\.Chars/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}defimpl String\.Chars/)
debugLog("Protocol implementations found:", parseResult.match(/defimpl[\s\S]*?end/g))
})

it("should parse behaviour callbacks", () => {
expect(parseResult).toMatch(/\d+--\d+ \| @callback test_behaviour_callback/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}@callback test_behaviour_callback/)
debugLog("Behaviour callbacks found:", parseResult.match(/@callback[\s\S]*?\)/g))
})

it("should parse struct definitions", () => {
expect(parseResult).toMatch(/\d+--\d+ \| defstruct \[/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}defstruct \[/)
debugLog("Struct definitions found:", parseResult.match(/defstruct[\s\S]*?\]/g))
})

it("should parse guard definitions", () => {
expect(parseResult).toMatch(/\d+--\d+ \| defguard test_guard_definition/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}defguard test_guard_definition/)
debugLog("Guard definitions found:", parseResult.match(/defguard[\s\S]*?end/g))
})

it("should parse module attributes", () => {
expect(parseResult).toMatch(/\d+--\d+ \| @test_attribute_definition/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}@test_attribute_definition/)
expect(parseResult).toMatch(/\d+--\d+ \| @moduledoc/)
debugLog("Module attributes found:", parseResult.match(/@[\s\S]*?\]/g))
})

it("should parse test definitions", () => {
expect(parseResult).toMatch(/\d+--\d+ \| test "test_definition"/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}test "test_definition"/)
debugLog("Test definitions found:", parseResult.match(/test[\s\S]*?end/g))
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe("parseSourceCodeDefinitionsForFile with Python", () => {
it("should parse class and method definitions", () => {
expect(parseResult).toMatch(/\d+--\d+ \| class MultiLineDecoratedClass:/)
expect(parseResult).toMatch(/\d+--\d+ \| class MethodContainer:/)
expect(parseResult).toMatch(/\d+--\d+ \| def multi_line_method\(/)
expect(parseResult).toMatch(/\d+--\d+ \| {5}def multi_line_method\(/)
debugLog("Class and method definitions found:", parseResult)
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,21 @@ describe("parseSourceCodeDefinitionsForFile with Scala", () => {
})

it("should parse method declarations", () => {
expect(parseResult).toMatch(/\d+--\d+ \| def testMatch\(value: Any\): Int = value match/)
expect(parseResult).toMatch(/\d+--\d+ \| def processItems\(items: List\[Int\]\): List\[Int\]/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}def testMatch\(value: Any\): Int = value match/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}def processItems\(items: List\[Int\]\): List\[Int\]/)
})

it("should parse value declarations", () => {
expect(parseResult).toMatch(/\d+--\d+ \| lazy val heavyComputation: Int = \{/)
expect(parseResult).toMatch(/\d+--\d+ \| val immutableValue: Int = 42/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}lazy val heavyComputation: Int = \{/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}val immutableValue: Int = 42/)
})

it("should parse variable declarations", () => {
expect(parseResult).toMatch(/\d+--\d+ \| var mutableValue: String = "changeable"/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}var mutableValue: String = "changeable"/)
})

it("should parse type definitions", () => {
expect(parseResult).toMatch(/\d+--\d+ \| type StringMap\[T\] = Map\[String, T\]/)
expect(parseResult).toMatch(/\d+--\d+ \| {3}type StringMap\[T\] = Map\[String, T\]/)
})

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,53 +24,51 @@ describe("Solidity Source Code Definition Tests", () => {
})

it("should parse using directives", () => {
expect(parseResult).toMatch(/23--23 \| using MathLib for uint256;/)
expect(parseResult).toMatch(/23--23 \| {5}using MathLib for uint256;/)
})

it("should parse type declarations", () => {
expect(parseResult).toMatch(/25--30 \| struct UserInfo {/)
expect(parseResult).toMatch(/32--37 \| enum UserRole {/)
expect(parseResult).toMatch(/25--30 \| {5}struct UserInfo {/)
expect(parseResult).toMatch(/32--37 \| {5}enum UserRole {/)
})

it("should parse state variable declarations", () => {
expect(parseResult).toMatch(/39--39 \| uint256 private immutable totalSupply;/)
expect(parseResult).toMatch(/40--40 \| mapping\(address => UserInfo\) private users;/)
expect(parseResult).toMatch(/41--41 \| UserRole\[\] private roles;/)
expect(parseResult).toMatch(/39--39 \| {5}uint256 private immutable totalSupply;/)
expect(parseResult).toMatch(/40--40 \| {5}mapping\(address => UserInfo\) private users;/)
expect(parseResult).toMatch(/41--41 \| {5}UserRole\[\] private roles;/)
})
it("should parse function declarations", () => {
expect(parseResult).toMatch(/70--87 \| function transfer\(/)
expect(parseResult).toMatch(/89--93 \| function interfaceFunction\(/)
expect(parseResult).toMatch(/70--87 \| {5}function transfer\(/)
expect(parseResult).toMatch(/89--93 \| {5}function interfaceFunction\(/)
expect(parseResult).toMatch(/6--6 \| {5}function interfaceFunction\(uint256 value\) external returns \(bool\);/)
expect(parseResult).toMatch(
/6--6 \| function interfaceFunction\(uint256 value\) external returns \(bool\);/,
/12--14 \| {5}function add\(uint256 a, uint256 b\) internal pure returns \(uint256\) {/,
)
expect(parseResult).toMatch(
/12--14 \| function add\(uint256 a, uint256 b\) internal pure returns \(uint256\) {/,
)
expect(parseResult).toMatch(
/16--19 \| function subtract\(uint256 a, uint256 b\) internal pure returns \(uint256\) {/,
/16--19 \| {5}function subtract\(uint256 a, uint256 b\) internal pure returns \(uint256\) {/,
)
})

it("should parse constructor declarations", () => {
expect(parseResult).toMatch(/63--68 \| constructor\(uint256 _initialSupply\) {/)
expect(parseResult).toMatch(/63--68 \| {5}constructor\(uint256 _initialSupply\) {/)
})

it("should parse special function declarations", () => {
expect(parseResult).toMatch(/95--97 \| fallback\(\) external payable {/)
expect(parseResult).toMatch(/99--101 \| receive\(\) external payable {/)
expect(parseResult).toMatch(/95--97 \| {5}fallback\(\) external payable {/)
expect(parseResult).toMatch(/99--101 \| {5}receive\(\) external payable {/)
})

it("should parse event declarations", () => {
expect(parseResult).toMatch(/43--47 \| event Transfer\(/)
expect(parseResult).toMatch(/7--7 \| event InterfaceEvent\(address indexed sender, uint256 value\);/)
expect(parseResult).toMatch(/43--47 \| {5}event Transfer\(/)
expect(parseResult).toMatch(/7--7 \| {5}event InterfaceEvent\(address indexed sender, uint256 value\);/)
})

it("should parse error declarations", () => {
expect(parseResult).toMatch(/49--53 \| error InsufficientBalance\(/)
expect(parseResult).toMatch(/8--8 \| error InterfaceError\(string message\);/)
expect(parseResult).toMatch(/49--53 \| {5}error InsufficientBalance\(/)
expect(parseResult).toMatch(/8--8 \| {5}error InterfaceError\(string message\);/)
})

it("should parse modifier declarations", () => {
expect(parseResult).toMatch(/55--61 \| modifier onlyAdmin\(\) {/)
expect(parseResult).toMatch(/55--61 \| {5}modifier onlyAdmin\(\) {/)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("TOML Source Code Definition Tests", () => {

it("should parse table arrays", () => {
expect(parseResult).toMatch(/\d+--\d+ \|\s*\[\[products\]\]/)
expect(parseResult).toMatch(/\d+--\d+ \|\s*\[\[products\]\] # Array of tables/)
expect(parseResult).toMatch(/\d+--\d+ \|\s*\[\[products\]\] {2}# Array of tables/)
})

it("should parse inline tables", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ describe("Zig Source Code Definition Tests", () => {

it("should parse function definitions", () => {
expect(parseResult).toMatch(/\d+--\d+ \| pub fn main\(\) !void/)
expect(parseResult).toMatch(/\d+--\d+ \| pub fn init\(x: f32, y: f32\) Point/)
expect(parseResult).toMatch(/\d+--\d+ \| pub fn distance\(self: Point\) f32/)
expect(parseResult).toMatch(/\d+--\d+ \| {5}pub fn init\(x: f32, y: f32\) Point/)
expect(parseResult).toMatch(/\d+--\d+ \| {5}pub fn distance\(self: Point\) f32/)
})

it("should parse container definitions", () => {
Expand Down
Loading