Comments (9)
Update: I'm sorry for not providing an actual example.
> assert = require "luassert"
> assert.is_true()
/usr/local/share/lua/5.2/luassert/assertions.lua:97: bad argument #2 to 'insert' (position out of bounds)
stack traceback:
[C]: in function 'insert'
/usr/local/share/lua/5.2/luassert/assertions.lua:97: in function 'callback'
/usr/local/share/lua/5.2/luassert/assert.lua:54: in function 'is_true'
stdin:1: in main chunk
[C]: in ?
The error is only raised under Lua >= 5.2.2.
I'll try to make a pull request fixing the issue.
from luassert.
This is what I get;
C:\Users\Thijs>lua52
Lua 5.2.1 Copyright (C) 1994-2012 Lua.org, PUC-Rio
> assert = require("luassert")
> assert.is_true()
stdin:1: Expected objects to be the same. Passed in:
(nil)
Expected:
true
stack traceback:
[C]: in function 'error'
...(x86)\LuaRocks\systree\share\lua\5.1\luassert\assert.lua:60: in function 'is_true'
stdin:1: in main chunk
[C]: in ?
>
Has your interpreter been compiled without the 'compatibility' flag?
What happens when you run the luassert test suite?
from luassert.
@Tieske, I checked Lua source and the check doesn't depend on the compatibility flag, but it was only introduced in Lua 5.2.2. 5.2.1 5.2.2
Luassert test suite fails, most errors are related to this issue.
from luassert.
It looks like the lua developers decided that table.insert should treat tables only as arrays as of lua 5.2.2. They do not allow insertion at arbitrary indices.
I suggest we change the offending line in assertions to read
arguments[2] = true
instead of
table.insert(arguments, 2, true)
from luassert.
This will need to be changed for the other assertions as well. I don't understand why they did this to us. The change in lua 5.2 seems...silly. The only thing I can think of is that they didn't want undefined behavior for sparse arrays?
from luassert.
I think the best solution would be to create a local tinsert()
function that does the right thing and replace all calls to table.insert()
with that.
from luassert.
What is your reasoning on why calling tinsert is best?
from luassert.
There is even utils.tinsert implemented already which seems to do the right thing.
from luassert.
@DorianGray because stock Lua is bad at handling nils. And luassert really needs it. That is why utils.tinsert was added in the first place.
Imo it would provide least chance of problems
@mpeterv thanks for bringing that back to memory!
from luassert.
Related Issues (20)
- Website not work HOT 2
- Feature request: Print passed in and expected arguments for assert.spy HOT 6
- Feature request: support for "eventually" (willing to PR) HOT 7
- Type introspection on spies? HOT 2
- is_calleable assertion HOT 7
- spy `was_called_with` fails when `self` is touched
- Add ability to suppress display of crumbs
- Complete, exhaustive reference? HOT 2
- [Question] New version of luassert? HOT 10
- assertions for log files HOT 1
- The extract_keys method may fail if the token has three or more words HOT 5
- How to make spy (or mock or stub) not change function type? HOT 4
- How to output colors in a custom formatter? HOT 2
- Create spy/stub that replaces an original function with another function? HOT 1
- Combining same() and near() HOT 1
- Can't upgrade luassert via luarocks HOT 3
- Match._ throws error
- `assert.same` has poor performance and only compares depth of back references
- `same` does not deepcompare keys HOT 10
- assertion.returned_arguments.x appear to have the wrong assert failure message HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from luassert.