Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 function verifyInterface(name, instance, attributes) { | 1 function verifyInterface(name, instance, attributes) { |
|
jsbell
2014/07/31 20:37:23
We could rename this verify_interface... but then
asanka
2014/08/01 05:15:52
Good point. There are tests like this in w3c/web-p
| |
| 2 assert_true(name in self, | 2 assert_true(name in self, |
| 3 name + ' should be an defined type'); | 3 name + ' should be a defined type'); |
| 4 if (instance) { | 4 if (instance) { |
| 5 assert_true(instance instanceof self[name], | 5 assert_true(instance instanceof self[name], |
| 6 instance + ' should be an instance of ' + name); | 6 instance + ' should be an instance of ' + name); |
| 7 Object.keys(attributes || {}).forEach(function(attribute) { | 7 Object.keys(attributes || {}).forEach(function(attribute) { |
| 8 var type = attributes[attribute]; | 8 var type = attributes[attribute]; |
| 9 assert_true(attribute in instance, | 9 assert_true(attribute in instance, |
| 10 attribute + ' should be an attribute of ' + name); | 10 attribute + ' should be an attribute of ' + name); |
| 11 assert_equals(typeof instance[attribute], type, | 11 assert_equals(typeof instance[attribute], type, |
| 12 attribute + ' should be of type ' + type); | 12 attribute + ' should be of type ' + type); |
| 13 }); | 13 }); |
| 14 } | 14 } |
| 15 } | 15 } |
| OLD | NEW |