@@ -376,90 +376,6 @@ func TestScanner_Comments(t *testing.T) {
376376 }
377377}
378378
379- func TestScanner_BatchSeparator (t * testing.T ) {
380- tests := []struct {
381- name string
382- input string
383- expected []sqldocument.TokenType
384- }{
385- {
386- name : "go at start of file" ,
387- input : "go" ,
388- expected : []sqldocument.TokenType {
389- sqldocument .BatchSeparatorToken ,
390- sqldocument .EOFToken ,
391- },
392- },
393- {
394- name : "GO uppercase at start" ,
395- input : "GO" ,
396- expected : []sqldocument.TokenType {
397- sqldocument .BatchSeparatorToken ,
398- sqldocument .EOFToken ,
399- },
400- },
401- {
402- name : "go after newline" ,
403- input : "SELECT 1\n go" ,
404- expected : []sqldocument.TokenType {
405- sqldocument .ReservedWordToken , // SELECT
406- sqldocument .WhitespaceToken ,
407- sqldocument .NumberToken , // 1
408- sqldocument .WhitespaceToken ,
409- sqldocument .BatchSeparatorToken , // go
410- sqldocument .EOFToken ,
411- },
412- },
413- {
414- name : "go with trailing whitespace" ,
415- input : "go \n SELECT" ,
416- expected : []sqldocument.TokenType {
417- sqldocument .BatchSeparatorToken ,
418- sqldocument .WhitespaceToken ,
419- sqldocument .ReservedWordToken ,
420- sqldocument .EOFToken ,
421- },
422- },
423- {
424- name : "go mid-line is identifier" ,
425- input : "SELECT go FROM" ,
426- expected : []sqldocument.TokenType {
427- sqldocument .ReservedWordToken , // SELECT
428- sqldocument .WhitespaceToken ,
429- sqldocument .UnquotedIdentifierToken , // go (not batch separator)
430- sqldocument .WhitespaceToken ,
431- sqldocument .ReservedWordToken , // FROM
432- sqldocument .EOFToken ,
433- },
434- },
435- {
436- name : "go with comment after is malformed" ,
437- input : "go -- comment" ,
438- expected : []sqldocument.TokenType {
439- sqldocument .BatchSeparatorToken ,
440- sqldocument .WhitespaceToken ,
441- sqldocument .MalformedBatchSeparatorToken , // -- comment
442- sqldocument .EOFToken ,
443- },
444- },
445- }
446-
447- for _ , tt := range tests {
448- t .Run (tt .name , func (t * testing.T ) {
449- tokens := collectTokens (tt .input )
450- if len (tokens ) != len (tt .expected ) {
451- t .Fatalf ("expected %d tokens, got %d: %+v" , len (tt .expected ), len (tokens ), tokens )
452- }
453- for i , exp := range tt .expected {
454- if tokens [i ].Type != exp {
455- t .Errorf ("token %d: expected type %v, got %v (value: %q)" ,
456- i , exp , tokens [i ].Type , tokens [i ].Value )
457- }
458- }
459- })
460- }
461- }
462-
463379func TestScanner_Position (t * testing.T ) {
464380 input := "SELECT\n @var\n FROM"
465381 s := NewScanner ("test.sql" , input )
@@ -521,29 +437,6 @@ END`
521437 }
522438}
523439
524- func TestScanner_ToCommonToken (t * testing.T ) {
525- tests := []struct {
526- tsqlToken sqldocument.TokenType
527- commonToken sqldocument.TokenType
528- }{
529- {VarcharLiteralToken , sqldocument .StringLiteralToken },
530- {NVarcharLiteralToken , sqldocument .StringLiteralToken },
531- {BracketQuotedIdentifierToken , sqldocument .QuotedIdentifierToken },
532- {UnterminatedVarcharLiteralErrorToken , sqldocument .UnterminatedStringErrorToken },
533- {UnterminatedQuotedIdentifierErrorToken , sqldocument .UnterminatedStringErrorToken },
534- {sqldocument .NumberToken , sqldocument .NumberToken }, // passthrough
535- {sqldocument .WhitespaceToken , sqldocument .WhitespaceToken }, // passthrough
536- }
537-
538- for _ , tt := range tests {
539- result := ToCommonToken (tt .tsqlToken )
540- if result != tt .commonToken {
541- t .Errorf ("ToCommonToken(%v): expected %v, got %v" ,
542- tt .tsqlToken , tt .commonToken , result )
543- }
544- }
545- }
546-
547440func TestScanner_Clone (t * testing.T ) {
548441 input := "SELECT FROM WHERE"
549442 s := NewScanner ("test.sql" , input )
0 commit comments