Skip to content

Commit c966f91

Browse files
committed
implementation
1 parent ddff9e7 commit c966f91

File tree

6 files changed

+68
-0
lines changed

6 files changed

+68
-0
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
target/
2+
*.iml
3+
.idea
4+
.settings
5+
.classpath
6+
.project
7+
.cache
8+
.sbtserver
9+
project/.sbtserver
10+
tags
11+
nohup.out

build.sbt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
scalaVersion := "2.11.11"
2+
libraryDependencies += "com.lihaoyi" %%% "utest" % "0.5.3" % "test"
3+
libraryDependencies += "com.lihaoyi" %%% "scalatags" % "0.6.7"
4+
testFrameworks += new TestFramework("utest.runner.Framework")
5+
nativeLinkStubs := true
6+
enablePlugins(ScalaNativePlugin)

project/build.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sbt.version = 0.13.15

project/plugins.sbt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.3.3")

src/main/scala/hello/Hello.scala

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package hello
2+
import scalatags.Text.all._
3+
object Hello {
4+
def para(n: Int, m: Modifier*) = p(m, title := ("this is paragraph " + n))
5+
6+
val titleString = "This is my title"
7+
val firstParaString = "This is my first paragraph"
8+
9+
val page = html(
10+
head(script("console.log(1)")),
11+
body(
12+
h1(color := "red")(titleString),
13+
div(backgroundColor := "blue")(
14+
para(0, cls := "contentpara first", firstParaString),
15+
a(href := "www.google.com")(p("Goooogle")),
16+
for (i <- 0 until 5) yield para(i,
17+
cls := "contentpara",
18+
color := (if (i % 2 == 0) "red" else "green"),
19+
"Paragraph ",
20+
i
21+
)
22+
)
23+
)
24+
)
25+
26+
def main(args: Array[String]): Unit = println(page())
27+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package hello
2+
import utest._
3+
object HelloTests extends TestSuite{
4+
val tests = Tests{
5+
val txt = Hello.page.render
6+
'head - {
7+
val head = txt.take(txt.indexOf("<body"))
8+
'console - {
9+
assert(head.contains("console"))
10+
}
11+
'log - {
12+
assert(head.contains("log()"))
13+
}
14+
}
15+
'rest - {
16+
assert(txt.contains("Paragraph"))
17+
}
18+
'title - {
19+
assert(txt.indexOf(Hello.titleString) >= 0)
20+
}
21+
}
22+
}

0 commit comments

Comments
 (0)