Skip to content

Comments

Add a shallow comparison check to make comparing two tables easier.#1

Open
Raild3x wants to merge 4 commits intodphfox:mainfrom
Raild3x:patch-1
Open

Add a shallow comparison check to make comparing two tables easier.#1
Raild3x wants to merge 4 commits intodphfox:mainfrom
Raild3x:patch-1

Conversation

@Raild3x
Copy link
Contributor

@Raild3x Raild3x commented Feb 25, 2025

Currently comparing two tables for shallow equivalency can be a pain and causes syntax not inline with other tests. I propose an additional expect test for being able to compare two tables.

	describe("Append", function()
		test("should append values and maintain order", function()
			local queue = Queue.new()
			queue:Append(11)
			queue:Append(12)
			queue:Append(13)
			expect(queue:ToArray()).is_shallow_equal({11, 12, 13, 14}) -- example with added 14 to cause an inequivalency
		end)
	end)

image

Also included is a deep equal comparison check.

Currently comparing two tables for shallow equivalency can be a pain and causes syntax not inline with other tests. I propose an additional expect test for being able to compare two tables.
```lua
	describe("Append", function()
		test("should append values and maintain order", function()
			local queue = Queue.new()
			queue:Append(11)
			queue:Append(12)
			queue:Append(13)
			expect(queue:ToArray()).is_shallow_equal({11, 12, 13})
		end)
	end)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant