Skip to content

Commit

Permalink
Remove brackets from the typeof and default operators.
Browse files Browse the repository at this point in the history
  • Loading branch information
ForNeVeR committed Mar 3, 2013
1 parent 9c415f3 commit 7853628
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Lens.Parser/Grammar.fs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ value_exprRef := choice [attempt lvalue |>> Node.getterNode
attempt atomar_expr]
type_operator_exprRef := pipe2
<| (keyword "typeof" <|> keyword "default")
<| (token "(" >>? ``type`` .>>? token ")")
<| ``type``
<| Node.typeOperator
literalRef := choice [attempt <| token "()" |>> Node.unit
attempt <| keyword "null" |>> Node.nullNode
Expand Down
20 changes: 10 additions & 10 deletions Lens.Test/OperatorsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,24 @@ public class OperatorsTest
[Test]
public void TypeofTest()
{
TestType<int>("typeof(int)");
TestType<float>("typeof(float)");
TestType<object>("typeof(object)");
TestType<int>("typeof int");
TestType<float>("typeof float");
TestType<object>("typeof object");

TestType<Dictionary<int, Exception>>("typeof(Dictionary<int, System.Exception>)");
TestType<Dictionary<int, Exception>>("typeof Dictionary<int, System.Exception>");
}

[Test]
public void DefaultTest()
{
Test("default(int)", 0);
Test("default(float)", 0.0f);
Test("default(long)", 0L);
Test("default(bool)", false);
Test("default int", 0);
Test("default float", 0.0f);
Test("default long", 0L);
Test("default bool", false);

Test("default(string)", null);
Test("default string", null);

Test("default(Nullable<int>)", default(int?));
Test("default Nullable<int>", default(int?));
}

[Test]
Expand Down
4 changes: 2 additions & 2 deletions Lens.Test/ParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -627,15 +627,15 @@ log ex
[Test]
public void Typeof()
{
var src = "let a = typeof(int)";
var src = "let a = typeof int";
var result = Expr.Let("a", Expr.Typeof("int"));
Test(src, result);
}

[Test]
public void DefaultOf()
{
var src = "let b = default (System.Collections.Generic.List<int>)";
var src = "let b = default System.Collections.Generic.List<int>";
var result = Expr.Let("b", Expr.Default("System.Collections.Generic.List<int>"));
Test(src, result);
}
Expand Down

0 comments on commit 7853628

Please sign in to comment.