File: util_test.go

package info (click to toggle)
golang-github-tdewolff-parse 2.7.15-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 836 kB
  • sloc: makefile: 2
file content (26 lines) | stat: -rw-r--r-- 757 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package js

import (
	"testing"

	"github.com/tdewolff/test"
)

func TestAsIdentifierName(t *testing.T) {
	test.That(t, !AsIdentifierName([]byte("")))
	test.That(t, !AsIdentifierName([]byte("5")))
	test.That(t, AsIdentifierName([]byte("ab")))
	test.That(t, !AsIdentifierName([]byte("a=")))
}

func TestAsDecimalLiteral(t *testing.T) {
	test.That(t, !AsDecimalLiteral([]byte("")))
	test.That(t, !AsDecimalLiteral([]byte("a")))
	test.That(t, AsDecimalLiteral([]byte("12")))
	test.That(t, AsDecimalLiteral([]byte("12.56")))
	test.That(t, AsDecimalLiteral([]byte(".56")))
	test.That(t, !AsDecimalLiteral([]byte(".56a")))
	test.That(t, !AsDecimalLiteral([]byte(".")))
	test.That(t, AsDecimalLiteral([]byte("0")))
	test.That(t, !AsDecimalLiteral([]byte("00")))
}