Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(98)

Unified Diff: tests/com/google/caja/tools/jsdoc/UpdocParserTest.java

Issue 8706: First pass at a javascript auto-documentation tool (Closed) Base URL: http://google-caja.googlecode.com/svn/trunk/
Patch Set: First pass at a javascript auto-documentation tool Created 2 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/com/google/caja/tools/jsdoc/JsdocTest.java ('k') | tests/com/google/caja/tools/jsdoc/jsdoc_test.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/com/google/caja/tools/jsdoc/UpdocParserTest.java
===================================================================
--- tests/com/google/caja/tools/jsdoc/UpdocParserTest.java (revision 0)
+++ tests/com/google/caja/tools/jsdoc/UpdocParserTest.java (revision 0)
@@ -0,0 +1,104 @@
+// Copyright (C) 2008 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.caja.tools.jsdoc;
+
+import com.google.caja.lexer.CharProducer;
+import com.google.caja.lexer.ParseException;
+import com.google.caja.util.CajaTestCase;
+import com.google.caja.util.MoreAsserts;
+import com.google.caja.util.TestUtil;
+
+import java.util.Arrays;
+
+public class UpdocParserTest extends CajaTestCase {
+ public final void testParse1() throws Exception {
+ assertParsed(
+ ""
+ + "$ Math.abs(-5)\n"
+ + "# 5",
+
+ "Updoc",
+ " Run",
+ " SpecialOperation : FUNCTION_CALL",
+ " SpecialOperation : MEMBER_ACCESS",
+ " Reference",
+ " Identifier : Math",
+ " Reference",
+ " Identifier : abs",
+ " SimpleOperation : NEGATION",
+ " IntegerLiteral : 5",
+ " IntegerLiteral : 5");
+ }
+
+ public final void testParse2() throws Exception {
+ assertParsed(
+ ""
+ + "$ Math.abs(0)\n"
+ + "# 0\n"
+ + "$ abs(\n"
+ + " 0 / 0)\n"
+ + "# NaN",
+
+ "Updoc",
+ " Run",
+ " SpecialOperation : FUNCTION_CALL",
+ " SpecialOperation : MEMBER_ACCESS",
+ " Reference",
+ " Identifier : Math",
+ " Reference",
+ " Identifier : abs",
+ " IntegerLiteral : 0",
+ " IntegerLiteral : 0",
+ " Run",
+ " SpecialOperation : FUNCTION_CALL",
+ " Reference",
+ " Identifier : abs",
+ " SimpleOperation : DIVISION",
+ " IntegerLiteral : 0",
+ " IntegerLiteral : 0",
+ " Reference",
+ " Identifier : NaN");
+ }
+
+ public final void testRender() throws Exception {
+ assertEquals(
+ ""
+ + "$ Math.abs(0);\n"
+ + "# 0;\n"
+ + "$ abs(0 / 0);\n"
+ + "# NaN;",
+ render(updoc(fromString(
+ ""
+ + "$ Math.abs( 0 )\n"
+ + "# 0\n"
+ + "// comments can appear in updoc too\n"
+ + "$ abs(0/0)\n"
+ + "# NaN"))));
+ }
+
+ private void assertParsed(String input, String... golden)
+ throws ParseException {
+ MoreAsserts.assertListsEqual(
+ Arrays.asList(golden),
+ Arrays.asList(
+ TestUtil.format(
+ updoc(fromString(input))).split("\r\n?|\n")));
+ }
+
+ private Updoc updoc(CharProducer cp) throws ParseException {
+ UpdocParser p = new UpdocParser(mq);
+ return p.parseComplete(cp);
+ }
+}
« no previous file with comments | « tests/com/google/caja/tools/jsdoc/JsdocTest.java ('k') | tests/com/google/caja/tools/jsdoc/jsdoc_test.html » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld 855:fffdfa546f68