@@ -12,6 +12,7 @@ import { EOL } from 'os';
1212import * as vscode from 'vscode' ;
1313import * as path from 'path' ;
1414import * as settings from '../../client/common/configSettings' ;
15+ import { normalizeMarkedString } from '../textUtils' ;
1516
1617const pythonSettings = settings . PythonSettings . getInstance ( ) ;
1718const autoCompPath = path . join ( __dirname , '..' , '..' , '..' , 'src' , 'test' , 'pythonFiles' , 'autocomp' ) ;
@@ -54,7 +55,8 @@ suite('Hover Definition', () => {
5455 assert . equal ( `${ def [ 0 ] . range . start . line } ,${ def [ 0 ] . range . start . character } ` , '30,4' , 'Start position is incorrect' ) ;
5556 assert . equal ( `${ def [ 0 ] . range . end . line } ,${ def [ 0 ] . range . end . character } ` , '30,11' , 'End position is incorrect' ) ;
5657 assert . equal ( def [ 0 ] . contents . length , 1 , 'Invalid content items' ) ;
57- assert . equal ( def [ 0 ] . contents [ 0 ] , '```python' + EOL + 'def method1()' + EOL + '```' + EOL + 'This is method1' , 'function signature incorrect' ) ;
58+ const expectedContent = '```python' + EOL + 'def method1()' + EOL + '```' + EOL + 'This is method1' ;
59+ assert . equal ( normalizeMarkedString ( def [ 0 ] . contents [ 0 ] ) , expectedContent , 'function signature incorrect' ) ;
5860 } ) . then ( done , done ) ;
5961 } ) ;
6062
@@ -73,7 +75,7 @@ suite('Hover Definition', () => {
7375 assert . equal ( def . length , 1 , 'Definition length is incorrect' ) ;
7476 assert . equal ( `${ def [ 0 ] . range . start . line } ,${ def [ 0 ] . range . start . character } ` , '1,9' , 'Start position is incorrect' ) ;
7577 assert . equal ( `${ def [ 0 ] . range . end . line } ,${ def [ 0 ] . range . end . character } ` , '1,12' , 'End position is incorrect' ) ;
76- assert . equal ( def [ 0 ] . contents [ 0 ] , '```python' + EOL + 'def fun()' + EOL + '```' + EOL + 'This is fun' , 'Invalid conents' ) ;
78+ assert . equal ( normalizeMarkedString ( def [ 0 ] . contents [ 0 ] ) , '```python' + EOL + 'def fun()' + EOL + '```' + EOL + 'This is fun' , 'Invalid conents' ) ;
7779 } ) . then ( done , done ) ;
7880 } ) ;
7981
@@ -92,7 +94,7 @@ suite('Hover Definition', () => {
9294 assert . equal ( def . length , 1 , 'Definition length is incorrect' ) ;
9395 assert . equal ( `${ def [ 0 ] . range . start . line } ,${ def [ 0 ] . range . start . character } ` , '25,4' , 'Start position is incorrect' ) ;
9496 assert . equal ( `${ def [ 0 ] . range . end . line } ,${ def [ 0 ] . range . end . character } ` , '25,7' , 'End position is incorrect' ) ;
95- assert . equal ( def [ 0 ] . contents [ 0 ] , '```python' + EOL + 'def bar()' + EOL + '```' + EOL +
97+ assert . equal ( normalizeMarkedString ( def [ 0 ] . contents [ 0 ] ) , '```python' + EOL + 'def bar()' + EOL + '```' + EOL +
9698 '说明 - keep this line, it works' + EOL + 'delete following line, it works' +
9799 EOL + '如果存在需要等待审批或正在执行的任务,将不刷新页面' , 'Invalid conents' ) ;
98100 } ) . then ( done , done ) ;
@@ -113,7 +115,7 @@ suite('Hover Definition', () => {
113115 assert . equal ( def . length , 1 , 'Definition length is incorrect' ) ;
114116 assert . equal ( `${ def [ 0 ] . range . start . line } ,${ def [ 0 ] . range . start . character } ` , '1,5' , 'Start position is incorrect' ) ;
115117 assert . equal ( `${ def [ 0 ] . range . end . line } ,${ def [ 0 ] . range . end . character } ` , '1,16' , 'End position is incorrect' ) ;
116- assert . equal ( def [ 0 ] . contents [ 0 ] , '```python' + EOL +
118+ assert . equal ( normalizeMarkedString ( def [ 0 ] . contents [ 0 ] ) , '```python' + EOL +
117119 'def showMessage()' + EOL +
118120 '```' + EOL +
119121 'Кюм ут жэмпэр пошжим льаборэж, коммюны янтэрэсщэт нам ед, декта игнота ныморэ жят эи. ' + EOL +
@@ -182,7 +184,7 @@ suite('Hover Definition', () => {
182184 "Optionally, implement a getrandbits() method so that randrange()" + EOL +
183185 "can cover arbitrarily large ranges." ;
184186
185- assert . equal ( def [ 0 ] . contents [ 0 ] , documentation , 'Invalid conents' ) ;
187+ assert . equal ( normalizeMarkedString ( def [ 0 ] . contents [ 0 ] ) , documentation , 'Invalid conents' ) ;
186188 } ) . then ( done , done ) ;
187189 } ) ;
188190
@@ -201,7 +203,7 @@ suite('Hover Definition', () => {
201203 assert . equal ( def . length , 1 , 'Definition length is incorrect' ) ;
202204 assert . equal ( `${ def [ 0 ] . range . start . line } ,${ def [ 0 ] . range . start . character } ` , '12,5' , 'Start position is incorrect' ) ;
203205 assert . equal ( `${ def [ 0 ] . range . end . line } ,${ def [ 0 ] . range . end . character } ` , '12,12' , 'End position is incorrect' ) ;
204- assert . equal ( def [ 0 ] . contents [ 0 ] , '```python' + EOL +
206+ assert . equal ( normalizeMarkedString ( def [ 0 ] . contents [ 0 ] ) , '```python' + EOL +
205207 'def randint(a, b)' + EOL +
206208 '```' + EOL +
207209 'Return random integer in range [a, b], including both end points.' , 'Invalid conents' ) ;
@@ -223,7 +225,7 @@ suite('Hover Definition', () => {
223225 assert . equal ( def . length , 1 , 'Definition length is incorrect' ) ;
224226 assert . equal ( `${ def [ 0 ] . range . start . line } ,${ def [ 0 ] . range . start . character } ` , '8,11' , 'Start position is incorrect' ) ;
225227 assert . equal ( `${ def [ 0 ] . range . end . line } ,${ def [ 0 ] . range . end . character } ` , '8,15' , 'End position is incorrect' ) ;
226- assert . equal ( def [ 0 ] . contents [ 0 ] , '```python' + EOL +
228+ assert . equal ( normalizeMarkedString ( def [ 0 ] . contents [ 0 ] ) , '```python' + EOL +
227229 'def acos(x)' + EOL +
228230 '```' + EOL +
229231 'Return the arc cosine (measured in radians) of x.' , 'Invalid conents' ) ;
@@ -245,7 +247,7 @@ suite('Hover Definition', () => {
245247 assert . equal ( def . length , 1 , 'Definition length is incorrect' ) ;
246248 assert . equal ( `${ def [ 0 ] . range . start . line } ,${ def [ 0 ] . range . start . character } ` , '14,9' , 'Start position is incorrect' ) ;
247249 assert . equal ( `${ def [ 0 ] . range . end . line } ,${ def [ 0 ] . range . end . character } ` , '14,15' , 'End position is incorrect' ) ;
248- assert . equal ( def [ 0 ] . contents [ 0 ] , '```python' + EOL +
250+ assert . equal ( normalizeMarkedString ( def [ 0 ] . contents [ 0 ] ) , '```python' + EOL +
249251 'class Thread(group=None, target=None, name=None, args=(), kwargs=None, verbose=None)' + EOL +
250252 '```' + EOL +
251253 'Thread(self, group=None, target=None, name=None,' + EOL +
@@ -271,14 +273,15 @@ suite('Hover Definition', () => {
271273 } ) . then ( def => {
272274 assert . equal ( def . length , 1 , 'Definition length is incorrect' ) ;
273275 assert . equal ( def [ 0 ] . contents . length , 1 , 'Only expected one result' ) ;
274- if ( def [ 0 ] . contents [ 0 ] . toString ( ) . indexOf ( "```python" ) === - 1 ) {
275- assert . fail ( def [ 0 ] . contents [ 0 ] . toString ( ) , "" , "First line is incorrect" , "compare" ) ;
276+ const contents = normalizeMarkedString ( def [ 0 ] . contents [ 0 ] ) ;
277+ if ( contents . indexOf ( "```python" ) === - 1 ) {
278+ assert . fail ( contents , "" , "First line is incorrect" , "compare" ) ;
276279 }
277- if ( def [ 0 ] . contents [ 0 ] . toString ( ) . indexOf ( "Random number generator base class used by bound module functions." ) === - 1 ) {
278- assert . fail ( def [ 0 ] . contents [ 0 ] . toString ( ) , "" , "'Random number generator' message missing" , "compare" ) ;
280+ if ( contents . indexOf ( "Random number generator base class used by bound module functions." ) === - 1 ) {
281+ assert . fail ( contents , "" , "'Random number generator' message missing" , "compare" ) ;
279282 }
280- if ( def [ 0 ] . contents [ 0 ] . toString ( ) . indexOf ( "Class Random can also be subclassed if you want to use a different basic" ) === - 1 ) {
281- assert . fail ( def [ 0 ] . contents [ 0 ] . toString ( ) , "" , "'Class Random message' missing" , "compare" ) ;
283+ if ( contents . indexOf ( "Class Random can also be subclassed if you want to use a different basic" ) === - 1 ) {
284+ assert . fail ( contents , "" , "'Class Random message' missing" , "compare" ) ;
282285 }
283286 } ) . then ( done , done ) ;
284287 } ) ;
@@ -290,12 +293,13 @@ suite('Hover Definition', () => {
290293 const def = await vscode . commands . executeCommand < vscode . Hover [ ] > ( 'vscode.executeHoverProvider' , textDocument . uri , position ) ;
291294 assert . equal ( def . length , 1 , 'Definition length is incorrect' ) ;
292295 assert . equal ( def [ 0 ] . contents . length , 1 , 'Only expected one result' ) ;
293- if ( def [ 0 ] . contents [ 0 ] . toString ( ) . indexOf ( "def capitalize" ) === - 1 ) {
294- assert . fail ( def [ 0 ] . contents [ 0 ] . toString ( ) , "" , "'def capitalize' is missing" , "compare" ) ;
296+ const contents = normalizeMarkedString ( def [ 0 ] . contents [ 0 ] ) ;
297+ if ( contents . indexOf ( "def capitalize" ) === - 1 ) {
298+ assert . fail ( contents , "" , "'def capitalize' is missing" , "compare" ) ;
295299 }
296- if ( def [ 0 ] . contents [ 0 ] . toString ( ) . indexOf ( "Return a capitalized version of S" ) === - 1 &&
297- def [ 0 ] . contents [ 0 ] . toString ( ) . indexOf ( "Return a copy of the string S with only its first character" ) === - 1 ) {
298- assert . fail ( def [ 0 ] . contents [ 0 ] . toString ( ) , "" , "'Return a capitalized version of S/Return a copy of the string S with only its first character' message missing" , "compare" ) ;
300+ if ( contents . indexOf ( "Return a capitalized version of S" ) === - 1 &&
301+ contents . indexOf ( "Return a copy of the string S with only its first character" ) === - 1 ) {
302+ assert . fail ( contents , "" , "'Return a capitalized version of S/Return a copy of the string S with only its first character' message missing" , "compare" ) ;
299303 }
300304 } ) ;
301305} ) ;
0 commit comments