Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: build

on:
workflow_dispatch:
push:
branches:
- 'master'
tags:
- 'v*'
pull_request:

jobs:
Building:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
# https://github.com/actions/virtual-environments#available-environments
os: [ubuntu-latest]
steps:
- name: Checkout out source code
uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: 'true'
- name: Set up Go environment
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
id: go

- name: Cache Go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-

- name: make build
run: |
go test -v
3 changes: 1 addition & 2 deletions parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,6 @@ func parse(l *list.List) (map[Rule]map[string]string, error) {
styles[style] = value
}
}

continue
}

css[r] = styles
Expand All @@ -209,6 +207,7 @@ func parse(l *list.List) (map[Rule]map[string]string, error) {
styles = map[string]string{}
style, value = "", ""
isBlock = false
rule = make([]string, 0)
}
prevToken = token.typ()
}
Expand Down
12 changes: 8 additions & 4 deletions parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ rule {
t.Fatal("should error out")
}
})

}

func TestParseHarder(t *testing.T) {
Expand All @@ -104,6 +103,14 @@ rule2 {
if _, ok := css["rule2"]; !ok {
t.Fatal("missing rule 'rule2'")
}

if len(css["rule1"]) != 2 {
t.Fatalf("expected 2 styles for rule 'rule1', got %d", len(css["rule1"]))
}

if len(css["rule2"]) != 1 {
t.Fatalf("expected 1 style for rule 'rule2', got %d", len(css["rule2"]))
}
})
t.Run("PropertyWithSpace", func(t *testing.T) {
ex1 := `body {
Expand Down Expand Up @@ -149,7 +156,6 @@ rule1 {
if err != nil {
t.Fatal(err)
}

})
}

Expand Down Expand Up @@ -195,11 +201,9 @@ func TestParseSelectorGroup(t *testing.T) {
if _, ok := css["rule3"]; !ok {
t.Fatal("Missing '.rule3' rule")
}

}

func BenchmarkParser(b *testing.B) {

ex1 := ""
for i := 0; i < 100; i++ {
ex1 += fmt.Sprintf(`block%d {
Expand Down