lunarmodules / luassert

Assertion library for Lua
MIT License
202 stars 77 forks source link

issues comparing tables because of ordering #135

Closed mathieujobin closed 8 years ago

mathieujobin commented 8 years ago

I am testing lua tables and decoded json output for REST APIs and my tests keep failing because of table ordering. especially those without keys (AKA arrays)

I tried .same and .equals and I am getting same behavior is there a better assertion function I could use ?

even, sometimes, the tables looks exactly the same...

Passed in:

(table) {

  [1] = 'dev'

  [2] = 'test' }

Expected:

(table) {

  [1] = 'dev'

  [2] = 'test' }

thanks

mpeterv commented 8 years ago

Can you give some example code reproducing this behaviour?

DorianGray commented 8 years ago

You should be using .same here. .equals compares the table reference.

mathieujobin commented 8 years ago

thanks, I'll see if I can write a tests that reproduce this