RESOLVED FIXED 136272
Web Inspector: Write tests for ScriptSyntaxTree and fix bugs in the data structure
https://bugs.webkit.org/show_bug.cgi?id=136272
Summary Web Inspector: Write tests for ScriptSyntaxTree and fix bugs in the data stru...
Saam Barati
Reported 2014-08-26 18:00:17 PDT
Write some tests for ScriptSyntaxTree. A good would be to make sure it can parse all statements that we have AST nodes for.
Attachments
patch (26.16 KB, patch)
2014-08-27 19:09 PDT, Saam Barati
joepeck: review+
patch (28.23 KB, patch)
2014-08-28 17:22 PDT, Saam Barati
no flags
Radar WebKit Bug Importer
Comment 1 2014-08-26 18:01:16 PDT
Saam Barati
Comment 2 2014-08-27 19:09:52 PDT
Created attachment 237279 [details] patch Tests!
Joseph Pecoraro
Comment 3 2014-08-28 14:08:06 PDT
Comment on attachment 237279 [details] patch View in context: https://bugs.webkit.org/attachment.cgi?id=237279&action=review Nice! Some suggestions for a few more tests. > LayoutTests/inspector/model/parse-script-syntax-tree.html:203 > + node = makeNode("true;", true); > + InspectorTest.assert(node.type === WebInspector.ScriptSyntaxTree.NodeType.Literal); > + InspectorTest.assert(node.value === true); > + InspectorTest.assert(node.raw === "true"); We might want to also test a few other literals? "null" "/regex/ig" "0x10" "0777" "\"a\"" > LayoutTests/inspector/model/parse-script-syntax-tree.html:276 > + node = makeNode("x = {foo:20};", true); > + InspectorTest.assert(node.right.properties[0].type === WebInspector.ScriptSyntaxTree.NodeType.Property); > + InspectorTest.assert(node.right.properties[0].key); > + InspectorTest.assert(node.right.properties[0].key.type === WebInspector.ScriptSyntaxTree.NodeType.Identifier); > + InspectorTest.assert(node.right.properties[0].value); > + InspectorTest.assert(node.right.properties[0].value.type === WebInspector.ScriptSyntaxTree.NodeType.Literal); > + node = makeNode("x = {'foo':20};", true); > + InspectorTest.assert(node.right.properties[0].key); > + InspectorTest.assert(node.right.properties[0].key.type === WebInspector.ScriptSyntaxTree.NodeType.Literal); > + InspectorTest.log("passed Property"); I'd suggest testing isGetterOrSetter is false here, and testing cases where it is true. "x = {get foo() {return 20}}" "x = {set foo(x) {}}" > LayoutTests/inspector/model/parse-script-syntax-tree.html:327 > + node = makeNode("foo++;", true); > + InspectorTest.assert(node.type === WebInspector.ScriptSyntaxTree.NodeType.UpdateExpression); > + InspectorTest.log("passed UpdateExpression"); Include a test for prefix === false here and a pre-increment/decrement with prefix === true.
Saam Barati
Comment 4 2014-08-28 17:22:26 PDT
Created attachment 237334 [details] patch Made additions Joe suggested
Joseph Pecoraro
Comment 5 2014-08-28 18:08:07 PDT
Comment on attachment 237334 [details] patch r=me
WebKit Commit Bot
Comment 6 2014-08-28 18:42:32 PDT
Comment on attachment 237334 [details] patch Clearing flags on attachment: 237334 Committed r173103: <http://trac.webkit.org/changeset/173103>
WebKit Commit Bot
Comment 7 2014-08-28 18:42:35 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.