Skip to content

Commit

Permalink
Implitic property value now also works for bool?
Browse files Browse the repository at this point in the history
  • Loading branch information
exyi committed Aug 7, 2017
1 parent f576d1a commit 2534124
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
26 changes: 13 additions & 13 deletions src/DotVVM.Framework.Tests.Common/Parser/Dothtml/DothtmlParserTests.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ @basetype Test

Assert.AreEqual(1, result.Content.Count);
Assert.IsInstanceOfType(result.Content[0], typeof(DothtmlLiteralNode));
Assert.AreEqual("\r\nthis is a content", ((DothtmlLiteralNode)result.Content[0]).Value);
Assert.AreEqual("\nthis is a content", ((DothtmlLiteralNode)result.Content[0]).Value);
}

[TestMethod]
Expand All @@ -218,7 +218,7 @@ public void DothtmlParser_Valid_Doctype()

Assert.AreEqual(1, result.Content.Count);
Assert.IsInstanceOfType(result.Content[0], typeof(DothtmlLiteralNode));
Assert.AreEqual("\r\n<!DOCTYPE html>\r\ntest", ((DothtmlLiteralNode)result.Content[0]).Value);
Assert.AreEqual("\n<!DOCTYPE html>\ntest", ((DothtmlLiteralNode)result.Content[0]).Value);
}


Expand Down Expand Up @@ -391,7 +391,7 @@ public void DothtmlParser_Valid_CData()
[TestMethod]
public void DothtmlParser_Valid_CommentBeforeDirective()
{
var markup = "<!-- my comment --> @viewModel TestDirective\r\nTest";
var markup = "<!-- my comment --> @viewModel TestDirective\nTest";
var root = ParseMarkup(markup);
var nodes = root.Content;

Expand All @@ -414,7 +414,7 @@ public void DothtmlParser_Valid_CommentBeforeDirective()
[TestMethod]
public void DothtmlParser_Valid_CommentInsideDirectives()
{
var markup = "@masterPage hello\r\n<!-- my comment --> @viewModel TestDirective\r\nTest";
var markup = "@masterPage hello\n<!-- my comment --> @viewModel TestDirective\nTest";
var root = ParseMarkup(markup);
var nodes = root.Content;

Expand Down Expand Up @@ -450,11 +450,11 @@ public void BindingParser_TextBinding_Invalid_MissingName()
[TestMethod]
public void DothtmlParser_HierarchyBuildingVisitor_Element_InvalidTag()
{
var markup = "<!-- my comment --> @viewModel TestDirective\r\n<div><div><ul><li>item</li><ul><a href='lol'>link</a></div></div>";
var markup = "<!-- my comment --> @viewModel TestDirective\n<div><div><ul><li>item</li><ul><a href='lol'>link</a></div></div>";
var root = ParseMarkup(markup);

var visitor = new HierarchyBuildingVisitor {
CursorPosition = 62
CursorPosition = 61
};

root.Accept(visitor);
Expand All @@ -479,12 +479,12 @@ public void DothtmlParser_HierarchyBuildingVisitor_Element_InvalidTag()
[TestMethod]
public void DothtmlParser_HierarchyBuildingVisitor_Element_UnclosedTagContent()
{
var markup = "<!-- my comment --> @viewModel TestDirective\r\n<div><div><ul><li>\r\n\t\t\t\t<a href='lol'></a></li></ul>\r\n</div></div>";
var markup = "<!-- my comment --> @viewModel TestDirective\n<div><div><ul><li>\n\t\t\t\t<a href='lol'></a></li></ul>\n</div></div>";
var root = ParseMarkup(markup);

var visitor = new HierarchyBuildingVisitor
{
CursorPosition = 83
CursorPosition = 81
};

root.Accept(visitor);
Expand Down Expand Up @@ -515,12 +515,12 @@ public void DothtmlParser_HierarchyBuildingVisitor_Element_UnclosedTagContent()
[TestMethod]
public void DothtmlParser_HierarchyBuildingVisitor_Element_Valid()
{
var markup = "<!-- my comment --> @viewModel TestDirective\r\n<div><div><ul><li>item</li></ul><a href='lol'>link</a></div></div>";
var markup = "<!-- my comment --> @viewModel TestDirective\n<div><div><ul><li>item</li></ul><a href='lol'>link</a></div></div>";
var root = ParseMarkup(markup);

var visitor = new HierarchyBuildingVisitor
{
CursorPosition = 62
CursorPosition = 61
};

root.Accept(visitor);
Expand All @@ -545,7 +545,7 @@ public void DothtmlParser_HierarchyBuildingVisitor_Element_Valid()
[TestMethod]
public void DothtmlParser_HierarchyBuildingVisitor_Attribute_TextValue()
{
var markup = "<!-- my comment --> @viewModel TestDirective\r\n<div><div><ul><li>item</li></ul><a href='lol'>link</a></div></div>";
var markup = "<!-- my comment --> @viewModel TestDirective\n<div><div><ul><li>item</li></ul><a href='lol'>link</a></div></div>";
var root = ParseMarkup(markup);

var visitor = new HierarchyBuildingVisitor
Expand Down Expand Up @@ -577,7 +577,7 @@ public void DothtmlParser_HierarchyBuildingVisitor_Attribute_TextValue()
[TestMethod]
public void DothtmlParser_HierarchyBuildingVisitor_Attribute_BindingValue()
{
var markup = "<!-- my comment --> @viewModel TestDirective\r\n<div><div><ul><li>item</li></ul><a href='{value: lol}'>link</a></div></div>";
var markup = "<!-- my comment --> @viewModel TestDirective\n<div><div><ul><li>item</li></ul><a href='{value: lol}'>link</a></div></div>";
var root = ParseMarkup(markup);

var visitor = new HierarchyBuildingVisitor
Expand Down Expand Up @@ -678,7 +678,7 @@ public void DothtmlParser_UnclosedTagImlicitlyClosed_WarningOnNode()
public static DothtmlRootNode ParseMarkup(string markup)
{
var tokenizer = new DothtmlTokenizer();
tokenizer.Tokenize(markup);
tokenizer.Tokenize(markup.Replace("\r\n", "\n"));
var parser = new DothtmlParser();
var node = parser.Parse(tokenizer.Tokens);
return node;
Expand Down
6 changes: 3 additions & 3 deletions src/DotVVM.Framework.Tests.Common/Parser/Dothtml/DothtmlTokenizerDirectivesTests.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public void DothtmlTokenizer_DirectiveParsing_Invalid_AtSymbol_DirectiveName_New
Assert.AreEqual(0, tokenizer.Tokens[i].Length);
Assert.AreEqual(DothtmlTokenType.DirectiveValue, tokenizer.Tokens[i++].Type);

Assert.AreEqual("\r\n", tokenizer.Tokens[i].Text);
Assert.AreEqual("\n", tokenizer.Tokens[i].Text);
Assert.AreEqual(DothtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type);

Assert.AreEqual("test", tokenizer.Tokens[i].Text);
Expand Down Expand Up @@ -239,7 +239,7 @@ public void DothtmlTokenizer_DirectiveParsing_Invalid_AtSymbol_DirectiveName_Spa
Assert.AreEqual(0, tokenizer.Tokens[i].Length);
Assert.AreEqual(DothtmlTokenType.DirectiveValue, tokenizer.Tokens[i++].Type);

Assert.AreEqual("\r\n", tokenizer.Tokens[i].Text);
Assert.AreEqual("\n", tokenizer.Tokens[i].Text);
Assert.AreEqual(DothtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type);

Assert.AreEqual("test", tokenizer.Tokens[i].Text);
Expand Down Expand Up @@ -272,7 +272,7 @@ public void DothtmlTokenizer_DirectiveParsing_Invalid_AtSymbol_Space_NewLine_Con
Assert.AreEqual(0, tokenizer.Tokens[i].Length);
Assert.AreEqual(DothtmlTokenType.DirectiveValue, tokenizer.Tokens[i++].Type);

Assert.AreEqual("\r\n", tokenizer.Tokens[i].Text);
Assert.AreEqual("\n", tokenizer.Tokens[i].Text);
Assert.AreEqual(DothtmlTokenType.WhiteSpace, tokenizer.Tokens[i++].Type);

Assert.AreEqual("test", tokenizer.Tokens[i].Text);
Expand Down
2 changes: 1 addition & 1 deletion src/DotVVM.Framework/Compilation/ControlTree/ControlTreeResolverBase.cs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ private void ProcessAttribute(DothtmlAttributeNode attribute, IAbstractControl c
if (attribute.ValueNode == null)
{
// implicitly set boolean property
if (property.PropertyType.IsEqualTo(new ResolvedTypeDescriptor(typeof(bool))))
if (property.PropertyType.IsEqualTo(new ResolvedTypeDescriptor(typeof(bool))) || property.PropertyType.IsEqualTo(new ResolvedTypeDescriptor(typeof(bool?))))
{
string error;
if (!treeBuilder.AddProperty(control, treeBuilder.BuildPropertyValue(property, true, attribute), out error)) attribute.AddError(error);
Expand Down

0 comments on commit 2534124

Please sign in to comment.