grim/xtrac
Clone
Summary
Browse
Changes
Graph
committing some old stuff
draft
default
tip
22 months ago, Gary Kramlich
2bd0417025e6
committing some old stuff
package
xtrac
import
(
"testing"
"github.com/stretchr/testify/assert"
)
func
tokenTest
(
t
*
testing
.
T
,
input
string
,
expected
[]
item
)
{
l
:=
lex
(
input
)
actual
:=
[]
item
{}
for
{
item
:=
l
.
nextItem
()
actual
=
append
(
actual
,
item
)
if
item
.
typ
==
itemEOF
{
break
}
}
assert
.
Equal
(
t
,
expected
,
actual
)
}
func
xTestBold
(
t
*
testing
.
T
)
{
input
:=
`'''bold''', ''' triple quotes !''' can be bold too if prefixed by ! '''`
items
:=
[]
item
{
item
{
typ
:
itemBold
,
val
:
"bold"
},
item
{
typ
:
itemText
,
val
:
", "
},
item
{
typ
:
itemBold
,
val
:
"triple quotes ''' can be bold too if prefixed by ! "
},
}
tokenTest
(
t
,
input
,
items
)
}
func
xTestItalic
(
t
*
testing
.
T
)
{
input
:=
`''italic''`
items
:=
[]
item
{
item
{
typ
:
itemItalic
,
val
:
"italic"
},
}
tokenTest
(
t
,
input
,
items
)
}
func
xTestBoldItalic
(
t
*
testing
.
T
)
{
input
:=
`'''''bolditalic'''''`
items
:=
[]
item
{
item
{
typ
:
itemBoldItalic
,
val
:
"bolditalic"
},
}
tokenTest
(
t
,
input
,
items
)
}
func
xTestUnderline
(
t
*
testing
.
T
)
{
input
:=
`__underline__`
items
:=
[]
item
{
item
{
typ
:
itemUnderline
,
val
:
"underline"
},
}
tokenTest
(
t
,
input
,
items
)
}
func
xTestStrikeThrough
(
t
*
testing
.
T
)
{
input
:=
`~~strike-through~~`
items
:=
[]
item
{
item
{
typ
:
itemStrikeThrough
,
val
:
"strike-through"
},
}
tokenTest
(
t
,
input
,
items
)
}
func
xTestSuperscript
(
t
*
testing
.
T
)
{
input
:=
`^superscript^`
items
:=
[]
item
{
item
{
typ
:
itemSuperscript
,
val
:
"superscript"
},
}
tokenTest
(
t
,
input
,
items
)
}
func
xTestSubscript
(
t
*
testing
.
T
)
{
input
:=
`,,subscript,,`
items
:=
[]
item
{
item
{
typ
:
itemSubscript
,
val
:
"subscript"
},
}
tokenTest
(
t
,
input
,
items
)
}
func
xTestCreole
(
t
*
testing
.
T
)
{
input
:=
`**also bold**, //italic as well//, and **'' bold italic **'' //(since 0.12)//`
items
:=
[]
item
{
item
{
typ
:
itemBold
,
val
:
"also bold"
},
item
{
typ
:
itemText
,
val
:
", "
},
item
{
typ
:
itemItalic
,
val
:
"italic as well"
},
item
{
typ
:
itemText
,
val
:
", and "
},
item
{
typ
:
itemBoldItalic
,
val
:
" bold italic "
},
item
{
typ
:
itemText
,
val
:
" "
},
item
{
typ
:
itemItalic
,
val
:
"(since 0.12)"
},
}
tokenTest
(
t
,
input
,
items
)
}