MCPcopy Create free account
hub / github.com/z7zmey/php-parser / TestSingleQuoteStringTokens

Function TestSingleQuoteStringTokens

scanner/scanner_test.go:539–584  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

537}
538
539func TestSingleQuoteStringTokens(t *testing.T) {
540 src := `<?php
541 'str $var str'
542
543 '\''
544
545 '\'
546 '
547
548 '\
549 \''
550
551 '\\'
552
553 '\\
554 '
555
556 '\
557 \''
558 `
559
560 expected := []string{
561 T_CONSTANT_ENCAPSED_STRING.String(),
562 T_CONSTANT_ENCAPSED_STRING.String(),
563 T_CONSTANT_ENCAPSED_STRING.String(),
564 T_CONSTANT_ENCAPSED_STRING.String(),
565 T_CONSTANT_ENCAPSED_STRING.String(),
566 T_CONSTANT_ENCAPSED_STRING.String(),
567 T_CONSTANT_ENCAPSED_STRING.String(),
568 }
569
570 lexer := NewLexer([]byte(src))
571 lv := &lval{}
572 actual := []string{}
573
574 for {
575 token := lexer.Lex(lv)
576 if token == 0 {
577 break
578 }
579
580 actual = append(actual, TokenID(token).String())
581 }
582
583 assert.DeepEqual(t, expected, actual)
584}
585
586func TestTeplateStringTokens(t *testing.T) {
587 src := `<?php

Callers

nothing calls this directly

Calls 4

LexMethod · 0.95
NewLexerFunction · 0.85
TokenIDTypeAlias · 0.85
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…