Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// Unit tests for dartdoc. | 5 /// Unit tests for dartdoc. |
| 6 #library('dartdoc_tests'); | 6 #library('dartdoc_test'); |
| 7 | 7 |
| 8 #import('../dartdoc.dart'); | 8 #import('../../../dartdoc/dartdoc.dart'); |
| 9 #import('../markdown.dart', prefix: 'md'); | 9 #import('../../../dartdoc/markdown.dart', prefix: 'md'); |
| 10 | 10 |
| 11 // TODO(rnystrom): Better path to unittest. | 11 // TODO(rnystrom): Better path to unittest. |
| 12 #import('../../../client/testing/unittest/unittest_node.dart'); | 12 #import('../../../../client/testing/unittest/unittest_node.dart'); |
| 13 #import('../../../frog/lang.dart'); | 13 #import('../../../../frog/lang.dart'); |
| 14 #import('../../../frog/file_system_node.dart'); | 14 #import('../../../../frog/file_system_node.dart'); |
| 15 | 15 |
| 16 main() { | 16 main() { |
| 17 var files = new NodeFileSystem(); | 17 var files = new NodeFileSystem(); |
| 18 parseOptions('../../frog', [], files); | 18 parseOptions('../../frog', [], files); |
| 19 initializeWorld(files); | 19 initializeWorld(files); |
| 20 | 20 |
| 21 group('countOccurrences', () { | 21 group('countOccurrences', () { |
| 22 test('empty text returns 0', () { | 22 test('empty text returns 0', () { |
| 23 expect(countOccurrences('', 'needle')).equals(0); | 23 expect(countOccurrences('', 'needle')).equals(0); |
| 24 }); | 24 }); |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 '../../other/sub/file.html'); | 110 '../../other/sub/file.html'); |
| 111 }); | 111 }); |
| 112 | 112 |
| 113 test('from nested to directory with different path', () { | 113 test('from nested to directory with different path', () { |
| 114 startFile('dir/sub/file.html'); | 114 startFile('dir/sub/file.html'); |
| 115 expect(relativePath('other/file.html')).equals( | 115 expect(relativePath('other/file.html')).equals( |
| 116 '../../other/file.html'); | 116 '../../other/file.html'); |
| 117 }); | 117 }); |
| 118 }); | 118 }); |
| 119 | 119 |
| 120 // TODO(rnystrom): Disabling these for now. The problem is that loading | |
|
Jennifer Messerly
2012/01/11 19:15:10
Up to you, but one thought I had here: instead of
Bob Nystrom
2012/01/11 21:28:47
Done: https://code.google.com/p/dart/issues/detail
| |
| 121 // dummy.dart is sensitive to the location that dart was invoked from and | |
| 122 // not relative to *this* file like we'd like. That means these tests only | |
| 123 // run correctly from one place. Unfortunately, test.py/test.dart runs this | |
| 124 // from one directory and frog/presubmit.py runs it from another. | |
| 125 /* | |
| 120 group('name reference', () { | 126 group('name reference', () { |
| 121 var doc = new Dartdoc(); | 127 var doc = new Dartdoc(); |
| 122 doc.document('test/dummy.dart'); | 128 // TODO(rnystrom): The paths here are a bit strange. They're relative to |
| 123 var dummy = world.libraries['test/dummy.dart']; | 129 // where test.dart happens to be invoked from. |
| 130 world.processDartScript('utils/tests/dartdoc/src/dummy.dart'); | |
| 131 world.resolveAll(); | |
| 132 var dummy = world.libraries['utils/tests/dartdoc/src/dummy.dart']; | |
| 124 var klass = dummy.findTypeByName('Class'); | 133 var klass = dummy.findTypeByName('Class'); |
| 125 var method = klass.getMember('method'); | 134 var method = klass.getMember('method'); |
| 126 | 135 |
| 127 String render(md.Node node) => md.renderToHtml([node]); | 136 String render(md.Node node) => md.renderToHtml([node]); |
| 128 | 137 |
| 129 test('to a parameter of the current method', () { | 138 test('to a parameter of the current method', () { |
| 130 expect(render(doc.resolveNameReference('param', member: method))). | 139 expect(render(doc.resolveNameReference('param', member: method))). |
| 131 equals('<span class="param">param</span>'); | 140 equals('<span class="param">param</span>'); |
| 132 }); | 141 }); |
| 133 | 142 |
| 134 test('to a member of the current type', () { | 143 test('to a member of the current type', () { |
| 135 expect(render(doc.resolveNameReference('method', type: klass))). | 144 expect(render(doc.resolveNameReference('method', type: klass))). |
| 136 equals('<a href="../../dummy/Class.html#method" class="crossref">' + | 145 equals('<a class="crossref" href="../../dummy/Class.html#method">' + |
| 137 'method</a>'); | 146 'method</a>'); |
| 138 }); | 147 }); |
| 139 | 148 |
| 140 test('to a property with only a getter links to the getter', () { | 149 test('to a property with only a getter links to the getter', () { |
| 141 expect(render(doc.resolveNameReference('getterOnly', type: klass))). | 150 expect(render(doc.resolveNameReference('getterOnly', type: klass))). |
| 142 equals('<a href="../../dummy/Class.html#get:getterOnly" ' + | 151 equals('<a class="crossref" ' + |
| 143 'class="crossref">getterOnly</a>'); | 152 'href="../../dummy/Class.html#get:getterOnly">getterOnly</a>'); |
| 144 }); | 153 }); |
| 145 | 154 |
| 146 test('to a property with only a setter links to the setter', () { | 155 test('to a property with only a setter links to the setter', () { |
| 147 expect(render(doc.resolveNameReference('setterOnly', type: klass))). | 156 expect(render(doc.resolveNameReference('setterOnly', type: klass))). |
| 148 equals('<a href="../../dummy/Class.html#set:setterOnly" ' + | 157 equals('<a class="crossref" ' + |
| 149 'class="crossref">setterOnly</a>'); | 158 'href="../../dummy/Class.html#set:setterOnly">setterOnly</a>'); |
| 150 }); | 159 }); |
| 151 | 160 |
| 152 test('to a property with a getter and setter links to the getter', () { | 161 test('to a property with a getter and setter links to the getter', () { |
| 153 expect(render(doc.resolveNameReference('getterAndSetter', type: klass))). | 162 expect(render(doc.resolveNameReference('getterAndSetter', type: klass))). |
| 154 equals('<a href="../../dummy/Class.html#get:getterAndSetter" ' + | 163 equals('<a class="crossref" ' + |
| 155 'class="crossref">getterAndSetter</a>'); | 164 'href="../../dummy/Class.html#get:getterAndSetter">' + |
| 165 'getterAndSetter</a>'); | |
| 156 }); | 166 }); |
| 157 | 167 |
| 158 test('to a type in the current library', () { | 168 test('to a type in the current library', () { |
| 159 expect(render(doc.resolveNameReference('Class', library: dummy))). | 169 expect(render(doc.resolveNameReference('Class', library: dummy))). |
| 160 equals('<a href="../../dummy/Class.html" class="crossref">Class</a>'); | 170 equals('<a class="crossref" href="../../dummy/Class.html">Class</a>'); |
| 161 }); | 171 }); |
| 162 | 172 |
| 163 test('to a top-level member in the current library', () { | 173 test('to a top-level member in the current library', () { |
| 164 expect(render(doc.resolveNameReference('topLevelMethod', | 174 expect(render(doc.resolveNameReference('topLevelMethod', |
| 165 library: dummy))). | 175 library: dummy))). |
| 166 equals('<a href="../../dummy.html#topLevelMethod" class="crossref">' + | 176 equals('<a class="crossref" href="../../dummy.html#topLevelMethod">' + |
| 167 'topLevelMethod</a>'); | 177 'topLevelMethod</a>'); |
| 168 }); | 178 }); |
| 169 | 179 |
| 170 test('to an unknown name', () { | 180 test('to an unknown name', () { |
| 171 expect(render(doc.resolveNameReference('unknownName', library: dummy, | 181 expect(render(doc.resolveNameReference('unknownName', library: dummy, |
| 172 type: klass, member: method))). | 182 type: klass, member: method))). |
| 173 equals('<code>unknownName</code>'); | 183 equals('<code>unknownName</code>'); |
| 174 }); | 184 }); |
| 175 }); | 185 }); |
| 186 */ | |
| 176 } | 187 } |
| OLD | NEW |