Opened 14 years ago

Closed 9 years ago

#4184 closed enhancement (wontfix)

[doh] check for accidental global variables

Reported by: skinner Owned by: dylan
Priority: low Milestone: future
Component: TestFramework Version: 0.9
Keywords: needsreview Cc:
Blocked By: Blocking:

Description (last modified by bill)

This is an enhancement suggestion for the doh test framework.

In JavaScript, it's easy to accidentally leave out "var" statements and create unintended global variables. For example, by writing a line of code like this:

typeMap = this._datatypeMap[type];

when what you meant to do was this:

var typeMap = this._datatypeMap[type];

Would be possible to add a feature to doh to check for unintended global variables? It would be great to be able to run the entire set of dojo unit tests and afterward check to make sure that the only global variable that got added was "dojo".

Before running a test group, doh could check to see what global variables were initially defined. After running the test group, doh could see if any new global variables have been defined. If doh was asked to report stray global variables, then doh could report an error if any new global variables were found.

In some cases the code being tested may intentionally create global variables. For example, intentionally creates a global variable. In cases like that, perhaps the unit test group could pre-register those intentional global variables with doh, so those variables wouldn't trigger an error.

This idea was discussed in the ticket for bug #3824, and has also been mentioned in some other recent ticket.

Change History (5)

comment:1 Changed 14 years ago by dylan

Milestone: 1.3

comment:2 Changed 13 years ago by bill

Description: modified (diff)
Milestone: 1.3future

move unowned / abandoned tickets to "future" milestone

comment:3 Changed 11 years ago by Chris Mitchell

Owner: changed from alex to dylan

please review/triage

comment:4 Changed 10 years ago by ben hockey

Keywords: needsreview added

comment:5 Changed 9 years ago by dylan

Resolution: wontfix
Status: newclosed

It's better to do this with JSHint, or perhaps the new TestStack?. Either way, closing this out.

Note: See TracTickets for help on using tickets.