nodeca/argparse — pull request #34 by hpaulj (2013-01-04 08:06:45+00:00)
Title: Use of _.indexOf to search a Namespace is wrong

ArgumentParser.parseKnownArgs() twice uses _indexOf(namespace, ...) to check the namespace object has a value. It should use _.has() instead (or a corrected Namespace.isset()).
---------------------
This argparse fails test_argparse.py TestOptionalsActionAppendConstWithDefault class.

This test has two actions with the same 'dest'. The Python test expects
the defaultValue of the 1st action to apply, but the JS code uses the 2nd's
defaultValue (or lack there of).

The correction is to change how ArgumentParser.parseKnownArgs() checks the
namespace for a value. A namespace is object-like, so indexOf is wrong.
Change this to _.has(). The indexOf version, besides applying to the wrong
kind of object, always returns true (the key is never found).

Namespace handling could be cleaned up. Sometimes it is accessed with
object methods, sometimes with its own set and isset. Also its handling
of null differs from the Python (more on this in another pull).