Commit bc385c2287d64412e756a6c3e0a6650d90c414d6

Golmote 2015-08-26T08:17:09

Merge pull request #684 from Golmote/tests-aspnet Add tests for ASP.NET

diff --git a/tests/languages/aspnet/comment_feature.test b/tests/languages/aspnet/comment_feature.test
new file mode 100644
index 0000000..da388e5
--- /dev/null
+++ b/tests/languages/aspnet/comment_feature.test
@@ -0,0 +1,16 @@
+<%----%>
+<%--foo--%>
+<%-- foo
+bar --%>
+
+----------------------------------------------------
+
+[
+	["asp comment", "<%----%>"],
+	["asp comment", "<%--foo--%>"],
+	["asp comment", "<%-- foo\r\nbar --%>"]
+]
+
+----------------------------------------------------
+
+Checks for comments.
\ No newline at end of file
diff --git a/tests/languages/aspnet/page-directive_feature.test b/tests/languages/aspnet/page-directive_feature.test
new file mode 100644
index 0000000..3d79dae
--- /dev/null
+++ b/tests/languages/aspnet/page-directive_feature.test
@@ -0,0 +1,92 @@
+<%@Assembly foo="bar"%>
+<% @Control foo="bar" %>
+<%@ Implements%>
+<%@Import%>
+<%@Master%>
+<%@MasterType%>
+<%@OutputCache%>
+<%@Page%>
+<%@PreviousPageType%>
+<%@Reference%>
+<%@Register%>
+
+----------------------------------------------------
+
+[
+	["page-directive tag", [
+		["page-directive tag", "<%@Assembly"],
+		["attr-name", [
+			"foo"
+		]],
+		["attr-value", [
+			["punctuation", "="],
+			["punctuation", "\""],
+			"bar",
+			["punctuation", "\""]
+		]],
+		["page-directive tag", "%>"]
+	]],
+
+	["page-directive tag", [
+        ["page-directive tag", "<% @Control"],
+        ["attr-name", [
+            "foo"
+        ]],
+        ["attr-value", [
+            ["punctuation", "="],
+            ["punctuation", "\""],
+            "bar",
+            ["punctuation", "\""]
+        ]],
+        ["page-directive tag", "%>"]
+    ]],
+
+    ["page-directive tag", [
+        ["page-directive tag", "<%@ Implements"],
+        ["page-directive tag", "%>"]
+    ]],
+
+    ["page-directive tag", [
+        ["page-directive tag", "<%@Import"],
+        ["page-directive tag", "%>"]
+    ]],
+
+    ["page-directive tag", [
+        ["page-directive tag", "<%@Master"],
+        ["page-directive tag", "%>"]
+    ]],
+
+    ["page-directive tag", [
+        ["page-directive tag", "<%@MasterType"],
+        ["page-directive tag", "%>"]
+    ]],
+
+    ["page-directive tag", [
+        ["page-directive tag", "<%@OutputCache"],
+        ["page-directive tag", "%>"]
+    ]],
+
+    ["page-directive tag", [
+        ["page-directive tag", "<%@Page"],
+        ["page-directive tag", "%>"]
+    ]],
+
+    ["page-directive tag", [
+        ["page-directive tag", "<%@PreviousPageType"],
+        ["page-directive tag", "%>"]
+    ]],
+
+    ["page-directive tag", [
+        ["page-directive tag", "<%@Reference"],
+        ["page-directive tag", "%>"]
+    ]],
+
+    ["page-directive tag", [
+        ["page-directive tag", "<%@Register"],
+        ["page-directive tag", "%>"]
+    ]]
+]
+
+----------------------------------------------------
+
+Checks for all page directives.
\ No newline at end of file
diff --git a/tests/languages/csharp+aspnet/directive_feature.test b/tests/languages/csharp+aspnet/directive_feature.test
new file mode 100644
index 0000000..9eaa005
--- /dev/null
+++ b/tests/languages/csharp+aspnet/directive_feature.test
@@ -0,0 +1,71 @@
+<%: Page.Title %>
+<%#:Item.ProductID%>
+<a href="ProductDetails.aspx?productID=<%#:Item.ProductID%>">
+<% if(foo) { %>
+	foobar
+<% } %>
+
+----------------------------------------------------
+
+[
+	["directive tag", [
+		["directive tag", "<%:"],
+		" Page",
+		["punctuation", "."],
+		"Title ",
+		["directive tag", "%>"]
+	]],
+
+	["directive tag", [
+        ["directive tag", "<%#:"],
+        "Item",
+        ["punctuation", "."],
+        "ProductID",
+        ["directive tag", "%>"]
+    ]],
+
+    ["tag", [
+        ["tag", [
+            ["punctuation", "<"],
+            "a"
+        ]],
+        ["attr-name", [
+            "href"
+        ]],
+        ["attr-value", [
+            ["punctuation", "="],
+            ["punctuation", "\""],
+            "ProductDetails.aspx?productID",
+            ["punctuation", "="],
+            ["directive tag", [
+                ["directive tag", "<%#:"],
+                "Item",
+		        ["punctuation", "."],
+		        "ProductID",
+		        ["directive tag", "%>"]
+            ]],
+            ["punctuation", "\""]
+        ]],
+        ["punctuation", ">"]
+    ]],
+
+    ["directive tag", [
+        ["directive tag", "<%"],
+        ["keyword", "if"],
+        ["punctuation", "("],
+        "foo",
+        ["punctuation", ")"],
+        ["punctuation", "{"],
+        ["directive tag", "%>"]
+    ]],
+    "\r\n\tfoobar\r\n",
+    ["directive tag", [
+        ["directive tag", "<%"],
+        ["punctuation", "}"],
+        ["directive tag", "%>"]
+    ]]
+]
+
+----------------------------------------------------
+
+Checks for directives.
\ No newline at end of file
diff --git a/tests/languages/markup+javascript+csharp+aspnet/script_feature.test b/tests/languages/markup+javascript+csharp+aspnet/script_feature.test
new file mode 100644
index 0000000..80c1ef8
--- /dev/null
+++ b/tests/languages/markup+javascript+csharp+aspnet/script_feature.test
@@ -0,0 +1,56 @@
+<script runat="server">#foo</script>
+<script>/foo/</script>
+
+----------------------------------------------------
+
+[
+	["asp script", [
+		["tag", [
+			["tag", [
+				["punctuation", "<"],
+				"script"
+			]],
+			["attr-name", [
+				"runat"
+			]],
+			["attr-value", [
+				["punctuation", "="],
+				["punctuation", "\""],
+				"server",
+				["punctuation", "\""]
+			]],
+			["punctuation", ">"]
+		]],
+		["preprocessor", "#foo"],
+		["tag", [
+			["tag", [
+				["punctuation", "</"],
+				"script"
+			]],
+			["punctuation", ">"]
+		]]
+	]],
+	["script", [
+		["tag", [
+			["tag", [
+				["punctuation", "<"],
+				"script"
+			]],
+			["punctuation", ">"]
+		]],
+		["regex", "/foo/"],
+		["tag", [
+			["tag", [
+				["punctuation", "</"],
+				"script"
+			]],
+			["punctuation", ">"]
+		]]
+	]]
+]
+
+----------------------------------------------------
+
+Checks for scripts containing C# code.
+Also checks that those don't break normal JS scripts.
+Note: Markup is loaded before Javascript so that scripts are added into grammar.
\ No newline at end of file