Flag accidental mutations in tests

This commit is contained in:
John Firebaugh
2012-11-26 21:08:33 -04:00
parent 1bb6915bad
commit 21ef3e4ce1
3 changed files with 18 additions and 2 deletions

View File

@@ -1,11 +1,16 @@
iD.Entity = function(a, b) {
if (!(this instanceof iD.Entity)) return new iD.Entity(a, b);
_.extend(this, a, b);
_.extend(this, {tags: {}}, a, b);
if (b) {
this.modified = true;
}
if (iD.debug) {
Object.freeze(this);
Object.freeze(this.tags);
}
};
iD.Entity.prototype = {

View File

@@ -1,6 +1,9 @@
iD.Graph = function(entities, annotation) {
if (!(this instanceof iD.Graph)) return new iD.Graph(entities, annotation);
this.entities = entities || {};
this.annotation = annotation;
for (var id in this.entities) {
// TODO: update extents that need it.
if (this.entities[id].type === 'way' && !this.entities[id]._extent) {
@@ -16,7 +19,11 @@ iD.Graph = function(entities, annotation) {
this.entities[id]._extent = extent;
}
}
this.annotation = annotation;
if (iD.debug) {
Object.freeze(this);
Object.freeze(this.entities);
}
};
iD.Graph.prototype = {

View File

@@ -53,6 +53,10 @@
<script type="text/javascript" src="spec/XML.js"></script>
<script type="text/javascript" src="spec/Inspector.js"></script>
<script type="text/javascript">
iD.debug = true;
</script>
<script type="text/javascript">
(function() {
var jasmineEnv = jasmine.getEnv();