Skip to content

Commit

Permalink
Add generate.go
Browse files Browse the repository at this point in the history
  • Loading branch information
yosssi committed Sep 7, 2014
1 parent 75aa902 commit 6204f39
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 4 deletions.
3 changes: 3 additions & 0 deletions element.go
@@ -1,7 +1,10 @@
package gcss

import "io"

// element represents an element of GCSS source codes.
type element interface {
io.WriterTo
AppendChild(child element)
Base() *elementBase
}
Expand Down
11 changes: 11 additions & 0 deletions generate.go
@@ -0,0 +1,11 @@
package gcss

func generate(elems []element) (<-chan string, <-chan error) {
sc := make(chan string)
errc := make(chan error)

go func() {
sc <- ""
}()
return sc, errc
}
11 changes: 11 additions & 0 deletions generate_test.go
@@ -0,0 +1,11 @@
package gcss

import "testing"

func Test_generate(t *testing.T) {
sc, errc := generate(nil)
select {
case <-sc:
case <-errc:
}
}
6 changes: 3 additions & 3 deletions parse.go
Expand Up @@ -18,7 +18,7 @@ func parse(s string) (<-chan []element, <-chan error) {
errc := make(chan error)

go func() {
var elements []element
var elems []element

lines := strings.Split(formatLF(s), lf)

Expand All @@ -43,11 +43,11 @@ func parse(s string) (<-chan []element, <-chan error) {
return
}

elements = append(elements, e)
elems = append(elems, e)
}
}

elemsc <- elements
elemsc <- elems
}()

return elemsc, errc
Expand Down
6 changes: 6 additions & 0 deletions selector.go
@@ -1,10 +1,16 @@
package gcss

import "io"

// selector represents a selector.
type selector struct {
elementBase
}

func (sel *selector) WriteTo(w io.Writer) (n int64, err error) {
return 0, nil
}

// newSelector creates and returns a selector.
func newSelector(ln *line, parent element) *selector {
return &selector{
Expand Down
17 changes: 16 additions & 1 deletion selector_test.go
@@ -1,6 +1,21 @@
package gcss

import "testing"
import (
"io/ioutil"
"testing"
)

func Test_selector_WriteTo(t *testing.T) {
ln := newLine(1, "html")

sel := newSelector(ln, nil)

_, err := sel.WriteTo(ioutil.Discard)

if err != nil {
t.Errorf("err should be nil [err: %s]", err.Error())
}
}

func Test_newSelector(t *testing.T) {
ln := newLine(1, "html")
Expand Down

0 comments on commit 6204f39

Please sign in to comment.