/scalate-core/src/test/scala/org/fusesource/scalate/scaml/ScamlTemplateErrorTest.scala
http://github.com/scalate/scalate · Scala · 138 lines · 86 code · 13 blank · 39 comment · 3 complexity · 55acf3b1c0d5f04a6914726452bb5e0f MD5 · raw file
- /**
- * Copyright (C) 2009-2011 the original author or authors.
- * See the notice.md file distributed with this work for additional
- * information regarding copyright ownership.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
- package org.fusesource.scalate.scaml
- /**
- * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
- */
- class ScamlTemplateErrorTest extends ScamlTestSupport {
- testCompilerException(
- "Compile Error",
- """
- %html
- %body
- %ul
- - for (i <- unknown)
- %li= i
- """,
- "error: not found: value unknown")
- /////////////////////////////////////////////////////////////////////
- //
- // Tests for indentation inconsistencies
- //
- /////////////////////////////////////////////////////////////////////
- testRender(
- "valid indenting",
- """
- %html
- %two
- %three
- %two
- """, """
- <html>
- <two>
- <three></three>
- </two>
- <two></two>
- </html>
- """)
- testInvalidSyntaxException(
- "Inconsistent indent level detected: indented too shallow",
- """
- %html
- %two
- %tooshallow
- %two
- """,
- "Inconsistent indent level detected: indented too shallow at 3.4")
- testInvalidSyntaxException(
- "Inconsistent indent level detected: indented too shallow at root",
- """
- %html
- %two
- %toodeep
- %two
- """,
- "Inconsistent indent level detected: indented too shallow at 3.2")
- testInvalidSyntaxException(
- "Inconsistent indent level detected: indented too deep",
- """
- %html
- %two
- %toodeep
- %two
- """,
- "Inconsistent indent level detected: indented too deep at 3.6")
- testInvalidSyntaxException(
- "Inconsistent indent detected: indented with spaces but previous lines were indented with tabs",
- """
- %html
- %tab
- %spaces
- %tab
- """,
- "Inconsistent indent detected: indented with spaces but previous lines were indented with tabs at 3.3")
- // // https://github.com/scala/scala-parser-combinators/commit/a6b2b3999dab
- // if (!scala.util.Properties.versionNumberString.startsWith("2.10")) {
- // testInvalidSyntaxException(
- // "Unexpected comma in html attribute list",
- // """
- //%html
- // %tab(comma="common", error="true")
- // %p commas in attribute lists is a common errro
- //""",
- // "')' expected but ',' found at 2.22")
- // }
- // since scala-parser-combinators 1.1.2
- // https://github.com/scala/scala-parser-combinators/commit/a6b2b3999dab
- val scalaV = scala.util.Properties.versionNumberString
- if (!scalaV.startsWith("2.10")) {
- if (scalaV.startsWith("2.11")) {
- // scala-parser-combinators 1.1.1
- testInvalidSyntaxException(
- "Unexpected comma in html attribute list",
- """
- %html
- %tab(comma="common", error="true")
- %p commas in attribute lists is a common errro
- """,
- "')' expected but ',' found at 2.22")
- } else {
- testInvalidSyntaxException(
- "Unexpected comma in html attribute list",
- """
- %html
- %tab(comma="common", error="true")
- %p commas in attribute lists is a common errro
- """,
- "string matching regex '[ \\t]+' expected but '(' found at 2.7")
- }
- }
- }