lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

It was thus said that the Great Thijs Schreijer once stated:
> > On 23 Aug 2016, at 08:11, Sean Conner <> wrote:
> > 
> > It was thus said that the Great steve donovan once stated:
> >> On Tue, Aug 23, 2016 at 6:24 AM, Daurnimator <> 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('ARRAY',"8301820203820405",{ 1 , { 2 , 3 } , { 4 , 5 }})
		{ 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:

	  local x = {}
	  local ref = {}
	  return cbor.TYPE.ARRAY(3)
	      .. cbor.TYPE.ARRAY(x,ref)
	      .. cbor.TYPE.ARRAY(x,ref)
	      .. cbor.TYPE.ARRAY({})
	  assertf(type(v) == 'table',"_sharedref: wanted table got
	  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

  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)
      local d,_,t = cbor.decode(e)

    it('should be an array',function()
      local bin = hextobin "8301820203820405"
      local e   = cbor.encode { 1 , { 2 , 3 } , { 4 , 5 } }
      local d,_,t = cbor.decode(e)
      assert.are.same(d,{ 1 , { 2 , 3 } , { 4 , 5 } })

  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({})
	  local v,_,t = cbor.decode(e)
	  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])

 ... 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

> 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)

[1]	Points awarded to correctly identifying the four other langauges I
	just referenced.


[3]	I later came to not really like the reverse Polish notation and
	stack gyrations, which is why I don't use it.

[4]	A Unix shell.  As a group project, not only did it have to run Unix
	commands, support redirection and environment variable substitution,
	but support simple programming constructs like loops and
	non-environment variables.  I was able to finish the group project
	in a few hours.  Got an A on the project.

[5]	Concise Binary Object Representation (RFC-7049)