It was thus said that the Great Thijs Schreijer once stated:
On 23 Aug 2016, at 08:11, Sean Conner <sean@conman.org> wrote:
It was thus said that the Great steve donovan once stated:
On Tue, Aug 23, 2016 at 6:24 AM, Daurnimator <quae@daurnimator.com> wrote:
It's not that you assume it's bug free; but that you hope your bugs
and their bugs are uncorrelated.
Ah, good point. An argument for a completely brain dead yet convenient
enough test framework.
And still I ask---what does a framework buy you that assert() doesn't?
Other than (in my opinion) excessive overhead on a possibly buggy framework?
-spc (Still puzzled by all this ... )
lol
Why do you even use Lua,
Because it's the first non-BASIC interpreted langauge that wasn't written
by a programmer who hates programming, isn't postmodern line noise, an
opinionated piece of software that distrusts programmers, and is fast and
straightforward [1].
it’s a source of bugs,
Yes, I even found one [2]. It got fixed and I was happy.
write your own compiler/interpreter/language, is probably gonna be way
better and have lesser bugs.
Yeah, I've done that too. Back in college, when I was in my "Forth is
fascinating" phase [3]. Even used it to implement a class project that ran
fine the first time [4].
care about writing your deep tables comparison assertions? roll your own!
Ah, like I did for my CBOR [5] implementation? [6]
how about multiple tests using the same setup en teardown. Making sure
each test starts as clean as possible. Why re-use, write your own bug free
implementations of course!
sorry for the tone in the above, but the thread above is just hilarious.
And I'm *still* puzzled at what a testing framework *buys* you. I *might*
have created a "framework" to test my CBOR implemetation [7], but to me,
it's just a few functions that does the work. For instance:
test('UINT',"00",0)
test('UINT',"01",1)
test('UINT',"0A",10)
test('UINT',"17",23)
test('UINT',"1818",24)
test('false',"F4",false)
test('true',"F5",true)
test('null',"F6",nil)
test('BIN',"4401020304","\1\2\3\4")
test('TEXT',"60","")
test('TEXT',"6161","a")
test('TEXT',"6449455446","IETF")
test('ARRAY',"8301820203820405",{ 1 , { 2 , 3 } , { 4 , 5 }})
test('ARRAY',"98190102030405060708090a0b0c0d0e0f101112131415161718181819",
{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25})
(tests taken from RFC-7049)
The test function takes as a parameter the encoded type, a hexstring to
describe the encoded value (since it's binary) and the value it represents.
These are simple, and the test() function encodes the value, checks the
result against what it should be (the test() function converts the hexstring
into a binary string), then decodes the encoded value and compares it
against the original. Perhaps the most complex test is this one:
test('ARRAY',"83d81c80d81d0080",{{},{},{}},
function()
local x = {}
local ref = {}
return cbor.TYPE.ARRAY(3)
.. cbor.TYPE.ARRAY(x,ref)
.. cbor.TYPE.ARRAY(x,ref)
.. cbor.TYPE.ARRAY({})
end,
function(_,v)
assertf(type(v) == 'table',"_sharedref: wanted table got
%s",type(v))
assertf(#v == 3,"_sharedref: wanted a table of three entries")
assertf(type(v[1]) == 'table',"_sharedref: wanted v[1] as table")
assertf(type(v[2]) == 'table',"_sharedref: wanged v[2] as table")
assertf(type(v[3]) == 'table','_sharedref: wanted v[3] as table')
assertf(v[1] == v[2],"_sharedref: wanted first two tables equal")
return true
end)
There are two optional functions that can be passed in, one for encoding
and one for comparing the results of decoding. In this case, the value
{{},{},{}}, is not actually used, but is included to show kind of what the
result looks like.
Now, what would a (any) test framework buy me for this? Please, educate
me! I can't make you encode the above tests in a testing framework, but I
would like to see it done. I'm looking at Lua Spec and Busted (both seem
very similar in nature) and frankly, I don't see what:
describe('CBOR encoding/decoding tests',function()
desscribe('some simple tests',function()
it('should work',function()
local bin = hextobin "F4"
local e = cbor.encode(false)
assert.equals(bin,e)
local d,_,t = cbor.decode(e)
assert.equals(t,'false')
assert.equals(d,false)
end)
it('should be an array',function()
local bin = hextobin "8301820203820405"
local e = cbor.encode { 1 , { 2 , 3 } , { 4 , 5 } }
assert.equals(bin,e)
local d,_,t = cbor.decode(e)
assert.equals(t,'ARRAY')
assert.are.same(d,{ 1 , { 2 , 3 } , { 4 , 5 } })
end)
end)
describe('an array of arrays, with some the same array',function()
it('has an awful amount of overhead with this testing framework',function()
local bin = hextobin "83d81c80d81d0080"
local x = {}
local ref = {}
local e = cbor.TYPE.ARRAY(3)
.. cbor.TYPE.ARRAY(x,ref)
.. cbor.TYPE.ARRAY(x,ref)
.. cbor.TYPE.ARRAY({})
assert.equals(bin,e)
local v,_,t = cbor.decode(e)
assert.equals(t,"ARRAY")
assert.equals(type(v) == 'table')
assert.equals(#v == 3)
assert.equals(type(v[1]) == 'table')
assert.equals(type(v[2]) == 'table')
assert.equals(type(v[3]) == 'table')
assert.equals(v[1] == v[2])
end)
end)
end)
... yeah ... I'm just not seeing the benefit here.
Those frameworks have been used by many before you and will have far
lesser bugs than your own code (no matter how good you code),
My snarky answer to this is: heartbleed. How long did this escape
detection? In a library how many people used? For how critical a
situation?
Only in the simplest of cases one should use the basic asserts, anything
beyond that would benefit from a framework (or like the OP, when you have
resource constraints maybe)
Again, I keep asking ... what do these give me? What benefit? So far, it
seems to be a large amount of overhead for little gain.
Sorry Sean, usually read your posts with interest, but this time you made
me laugh.
-spc (Glad I could entertain you)