Tarantool development patches archive
 help / color / mirror / Atom feed
From: Alexander Turenko <alexander.turenko@tarantool.org>
To: Vladimir Davydov <vdavydov.dev@gmail.com>
Cc: Kirill Shcherbatov <kshcherbatov@tarantool.org>,
	tarantool-patches@freelists.org
Subject: Re: [tarantool-patches] Re: [PATCH v2 2/2] lua: add key_def lua module
Date: Wed, 3 Apr 2019 14:46:44 +0300	[thread overview]
Message-ID: <20190403114644.25bf3mull76xk7xp@tkn_work_nb> (raw)
In-Reply-To: <20190403111003.x7vq7olda55tthgi@esperanza>

> > +-- Case: extract_key().
> > +test:test('extract_key()', function(test)
> > +    test:plan(9)
> > +
> > +    test:is_deeply(key_def_a:extract_key(tuple_a):totable(), {1}, 'case 1')
> > +    test:is_deeply(key_def_b:extract_key(tuple_a):totable(), {1, 22}, 'case 2')
> > +
> > +    -- JSON path.
> > +    local res = key_def_lib.new({
> > +        {type = 'string', fieldno = 1, path = 'a.b'},
> > +    }):extract_key(box.tuple.new({{a = {b = 'foo'}}})):totable()
> > +    test:is_deeply(res, {'foo'}, 'JSON path (tuple argument)')
> > +
> > +    local res = key_def_lib.new({
> > +        {type = 'string', fieldno = 1, path = 'a.b'},
> > +    }):extract_key({{a = {b = 'foo'}}}):totable()
> > +    test:is_deeply(res, {'foo'}, 'JSON path (table argument)')
> 
> I like key_def_new_cases - they are very easy to read or extend.
> I don't quite like the tests below, because they refer to objects
> created a few screens above (tuple_a, key_def_a, etc). Could you
> please rewrite them in a similar to key_def_new_cases fashion,
> without referring to any predefined variables?

It is easy to separate test cases from a testing code in case of one
function like key_def.new(), but it is not so easy when we need to test
several functions with different behaviour. So I vote up for inlining
related data (tuple_a and so on) to test cases, but doubt these cases
could be written in such declarative manner as I did for key_def.new().

Thank you for the detailed review (eps. for the case that passes over
validation)!

WBR, Alexander Turenko.

  reply	other threads:[~2019-04-03 11:46 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-27 14:29 [tarantool-patches] [PATCH v2 0/2] " Kirill Shcherbatov
2019-03-27 14:29 ` [tarantool-patches] [PATCH v2 1/2] lua: add luaT_tuple_new() Kirill Shcherbatov
2019-03-28  9:01   ` [tarantool-patches] " Konstantin Osipov
2019-03-28  9:18     ` Alexander Turenko
2019-04-03 18:01   ` [tarantool-patches] " Vladimir Davydov
2019-04-04  2:51     ` Alexander Turenko
2019-04-04  8:14       ` Vladimir Davydov
2019-03-27 14:29 ` [tarantool-patches] [PATCH v2 2/2] lua: add key_def lua module Kirill Shcherbatov
2019-03-28  2:01   ` Alexander Turenko
2019-03-28  7:38     ` [tarantool-patches] " Kirill Shcherbatov
2019-03-28  8:41     ` Kirill Shcherbatov
     [not found]       ` <6d915212-e80f-4a6d-d884-b838bf25f8a7@tarantool.org>
2019-03-28 11:22         ` Alexander Turenko
2019-04-03 11:10           ` Vladimir Davydov
2019-04-03 11:46             ` Alexander Turenko [this message]
2019-04-03 12:01               ` Vladimir Davydov
2019-04-03 13:26                 ` Alexander Turenko
2019-04-04  5:07             ` Alexander Turenko
2019-04-04  8:04               ` Kirill Shcherbatov
2019-04-04  9:05                 ` Vladimir Davydov
2019-04-04 11:46                   ` Alexander Turenko
2019-04-04 14:36                     ` Vladimir Davydov
2019-04-04  8:38               ` Vladimir Davydov
2019-04-04 11:17                 ` Alexander Turenko
2019-04-04 12:00                   ` Alexander Turenko
2019-04-04 14:42                     ` Vladimir Davydov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190403114644.25bf3mull76xk7xp@tkn_work_nb \
    --to=alexander.turenko@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=vdavydov.dev@gmail.com \
    --subject='Re: [tarantool-patches] Re: [PATCH v2 2/2] lua: add key_def lua module' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox