Skip to content

Commit

Permalink
Test refer to Error object fullname, need to update.
Browse files Browse the repository at this point in the history
All tests pass now.
  • Loading branch information
Mike Stall committed Apr 29, 2022
1 parent e352866 commit 9b90c21
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Table({Double:2,Value:1},{Double:4,Value:2},{Double:6,Value:3},{Double:8,Value:4
Table({Blanks:Blank(),Value:1},{Blanks:Blank(),Value:2},{Blanks:Blank(),Value:3},{Blanks:Blank(),Value:4},{Blanks:Blank(),Value:5})

>> AddColumns([1,2,0,4,5], "Div", 20/Value)
Table({Div:20,Value:1},{Div:10,Value:2},{Div:Microsoft.PowerFx.Core.Public.Values.ErrorValue,Value:0},{Div:5,Value:4},{Div:4,Value:5})
Table({Div:20,Value:1},{Div:10,Value:2},{Div:Microsoft.PowerFx.Types.ErrorValue,Value:0},{Div:5,Value:4},{Div:4,Value:5})

>> AddColumns(Sort([-2, -1, 0, 1, 2], 1 / Value), "Double", Value * 2)
#Error(Kind=Div0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
Table({Result:"7"},{Result:"8"},{Result:"9"})

>> Char(["55", "Error Coercion", "57"])
Table({Result:"7"},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:"9"})
Table({Result:"7"},{Result:Microsoft.PowerFx.Types.ErrorValue},{Result:"9"})

>> Concatenate(123, "456")
"123456"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
4

>> Filter([1,2,0,3,4], 1/ThisRecord.Value >= 0)
Table({Value:1},{Value:2},Microsoft.PowerFx.Core.Public.Values.ErrorValue,{Value:3},{Value:4})
Table({Value:1},{Value:2},Microsoft.PowerFx.Types.ErrorValue,{Value:3},{Value:4})

>> Filter([1,2,0,3,4], Blank())
[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Errors: Error 0-25: The function 'Find' has some invalid arguments.|Error 5-9: I
Table({Result:1})

>> Find(If(false, ["blank table"], Blank()), If(false, ["blank table"], Blank()), [2])
Table({Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue})
Table({Result:Microsoft.PowerFx.Types.ErrorValue})

>> Find(If(false, ["blank table"], Blank()), "textToBeSearchedIn", [5])
Table({Result:5})
Expand All @@ -29,13 +29,13 @@ Table({Result:Blank()},{Result:Blank()})
Table()

>> Find([Blank(), "", ","], If(false, ["blank table"], Blank()), [1, 2, 3])
Table({Result:1},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue})
Table({Result:1},{Result:Microsoft.PowerFx.Types.ErrorValue},{Result:Microsoft.PowerFx.Types.ErrorValue})

>> Find(If(false, ["blank table"], Blank()), [Blank(), "", "textToBeSearchedIn"], 1)
Table({Result:1},{Result:1},{Result:1})

>> Find(If(false, ["blank table"], Blank()), [Blank(), "", "textToBeSearchedIn"], [1, 2, 3])
Table({Result:1},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:3})
Table({Result:1},{Result:Microsoft.PowerFx.Types.ErrorValue},{Result:3})

>> Find([Blank(), "", ","], "textToBeSearchedIn,textToBeSearchedIn", 1)
Table({Result:1},{Result:1},{Result:19})
Expand All @@ -47,7 +47,7 @@ Table({Result:1},{Result:2},{Result:19},{Result:Blank()})
Table({Result:19})

>> Find(",", ["textToBeSearchedIn,textToBeSearchedIn", "textToBeSearchedIn,textToBeSearchedIn,", "textToBeSearchedIn,textToBeSearchedIn"], [1, 20, 40])
Table({Result:19},{Result:38},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue})
Table({Result:19},{Result:38},{Result:Microsoft.PowerFx.Types.ErrorValue})

>> Find([Blank(), "", ","], ["textToBeSearchedIn,textToBeSearchedIn", "textToBeSearchedIn,textToBeSearchedIn,", "textToBeSearchedIn,textToBeSearchedIn"], [1, 10, 9])
Table({Result:1},{Result:10},{Result:19})
Expand Down Expand Up @@ -77,10 +77,10 @@ Table({Result:1},{Result:9},{Result:1},{Result:1})
Table({Result:1},{Result:9},{Result:1},{Result:Blank()})

>> Find([Blank(), ","], ["lastName,firstName",], [9, 2, 3])
Table({Result:9},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue})
Table({Result:9},{Result:Microsoft.PowerFx.Types.ErrorValue},{Result:Microsoft.PowerFx.Types.ErrorValue})

>> Find([Blank(), ",", "", "findMe"], [Blank(), "lastName,firstName"], 10)
Table({Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:Blank()},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue})
Table({Result:Microsoft.PowerFx.Types.ErrorValue},{Result:Blank()},{Result:Microsoft.PowerFx.Types.ErrorValue},{Result:Microsoft.PowerFx.Types.ErrorValue})

>> Find([",", Blank()], "lastName,firstName", [1, 2, 3])
Table({Result:9},{Result:2},{Result:3})
Expand Down Expand Up @@ -122,20 +122,20 @@ Table()
Table()

>> Find("c", Table({ within: "abc" }, { within: Error({Kind: ErrorKind.Validation}) }, { within: "cde" }))
Table({Result:3},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:1})
Table({Result:3},{Result:Microsoft.PowerFx.Types.ErrorValue},{Result:1})

>> Find("c", ["abc", Error({Kind: ErrorKind.Validation}), "cde"])
Table({Result:3},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:1})
Table({Result:3},{Result:Microsoft.PowerFx.Types.ErrorValue},{Result:1})

>> Find(Table({ find: "a" }, { find: Error({Kind: ErrorKind.Validation}) }, { find: "b" }), "abc")
Table({Result:1},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:2})
Table({Result:1},{Result:Microsoft.PowerFx.Types.ErrorValue},{Result:2})

>> Find(["a", Error({Kind: ErrorKind.Validation}), "b"], "abc")
Table({Result:1},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:2})
Table({Result:1},{Result:Microsoft.PowerFx.Types.ErrorValue},{Result:2})

>> Find(Table({ find: "a" }, { find: Mid("Hello", -1) }, { find: "b" }, If(1/0>2, { find: "e" }), { find: "c" }), Table({ within: "abc" }, If(Sqrt(-1)<0, { within: "err" }), { within: Left("err", -1) }, If(Right("err", -3) = "err", { within: "err" }), { within: "abc" }))
Table({Result:1},Microsoft.PowerFx.Core.Public.Values.ErrorValue,{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},Microsoft.PowerFx.Core.Public.Values.ErrorValue,{Result:3})
//actual: Microsoft.PowerFx.Core.Public.Values.ErrorValue
Table({Result:1},Microsoft.PowerFx.Types.ErrorValue,{Result:Microsoft.PowerFx.Types.ErrorValue},Microsoft.PowerFx.Types.ErrorValue,{Result:3})
//actual: Microsoft.PowerFx.Types.ErrorValue

>> Find(Table({ find: "a" }, { find: "b" }, { find: "c" }), If(1/0>2,"abcdef"))
#Error(Kind=Div0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ Blank()
#Error

>> ForAll(Table({Value:1,Zulu:1}, {Value:0,Zulu:0}, {Value:2,Zulu:2}), 1/ThisRecord.Value)
[1,Microsoft.PowerFx.Core.Public.Values.ErrorValue,0.5]
[1,Microsoft.PowerFx.Types.ErrorValue,0.5]

>> First(LastN(ForAll(Table({Value:1,Zulu:1}, {Value:0,Zulu:0}, {Value:2,Zulu:2}), 1/ThisRecord.Value), 2)).Value
#Error

>> Table({Value:1},First(LastN(ForAll(Table({Value:1,Zulu:1}, {Value:0,Zulu:0}, {Value:2,Zulu:2}), 1/ThisRecord.Value), 2)),{Value:2})
[1,Microsoft.PowerFx.Core.Public.Values.ErrorValue,2]
[1,Microsoft.PowerFx.Types.ErrorValue,2]

>> First(First(LastN(ForAll(Table({Value:1}, {Value:0}, {Value:2}), Table({a: 1/ThisRecord.Value})), 2)).Value)
{a:Microsoft.PowerFx.Core.Public.Values.ErrorValue}
{a:Microsoft.PowerFx.Types.ErrorValue}
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ Table()
#Error

>> Concatenate("a", ["hello", Mid("great", -1), "world"])
Table({Result:"ahello"},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:"aworld"})
Table({Result:"ahello"},{Result:Microsoft.PowerFx.Types.ErrorValue},{Result:"aworld"})

>> Concatenate("a", Table({a:"one"},If(1<0,{a:"two"}),{a:"three"}))
Table({Result:"aone"},{Result:"a"},{Result:"athree"})

>> Concatenate("a", Table({a:"one"},If(1/0<2,{a:"two"}),{a:"three"}))
Table({Result:"aone"},Microsoft.PowerFx.Core.Public.Values.ErrorValue,{Result:"athree"})
Table({Result:"aone"},Microsoft.PowerFx.Types.ErrorValue,{Result:"athree"})

>> Concatenate(Blank(), ["hello", Mid("great", -1), "world"])
Table({Result:"hello"},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:"world"})
Table({Result:"hello"},{Result:Microsoft.PowerFx.Types.ErrorValue},{Result:"world"})

>> Concatenate(Blank(), Table({a:"one"},If(1<0,{a:"two"}),{a:"three"}))
Table({Result:"one"},{Result:""},{Result:"three"})

>> Concatenate(Blank(), Table({a:"one"},If(1/0<2,{a:"two"}),{a:"three"}))
Table({Result:"one"},Microsoft.PowerFx.Core.Public.Values.ErrorValue,{Result:"three"})
Table({Result:"one"},Microsoft.PowerFx.Types.ErrorValue,{Result:"three"})

// Table + Scalar (Reverse Arguments)
>> Concatenate(Table({b:"1"},{b:"2"}), "a")
Expand All @@ -43,22 +43,22 @@ Table()
#Error

>> Concatenate(["hello", Mid("great", -1), "world"], "a")
Table({Result:"helloa"},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:"worlda"})
Table({Result:"helloa"},{Result:Microsoft.PowerFx.Types.ErrorValue},{Result:"worlda"})

>> Concatenate(Table({a:"one"},If(1<0,{a:"two"}),{a:"three"}), "a")
Table({Result:"onea"},{Result:"a"},{Result:"threea"})

>> Concatenate(Table({a:"one"},If(1/0<2,{a:"two"}),{a:"three"}), "a")
Table({Result:"onea"},Microsoft.PowerFx.Core.Public.Values.ErrorValue,{Result:"threea"})
Table({Result:"onea"},Microsoft.PowerFx.Types.ErrorValue,{Result:"threea"})

>> Concatenate(["hello", Mid("great", -1), "world"], Blank())
Table({Result:"hello"},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:"world"})
Table({Result:"hello"},{Result:Microsoft.PowerFx.Types.ErrorValue},{Result:"world"})

>> Concatenate(Table({a:"one"},If(1<0,{a:"two"}),{a:"three"}), Blank())
Table({Result:"one"},{Result:""},{Result:"three"})

>> Concatenate(Table({a:"one"},If(1/0<2,{a:"two"}),{a:"three"}), Blank())
Table({Result:"one"},Microsoft.PowerFx.Core.Public.Values.ErrorValue,{Result:"three"})
Table({Result:"one"},Microsoft.PowerFx.Types.ErrorValue,{Result:"three"})

// Table + Table
>> Concatenate(["one", "two"], [1, 2, 3, 4])
Expand All @@ -71,13 +71,13 @@ Table({Result:"one"},{Result:"two"})
Table({Result:"one"},{Result:"two"})

>> Concatenate(["one", "two"], If(1/0<2, ["txt"]))
Microsoft.PowerFx.Core.Public.Values.ErrorValue
Microsoft.PowerFx.Types.ErrorValue

>> Concatenate(["one", "two"], Table({a:"one"},If(1<0,{a:"two"}),{a:"three"}))
Table({Result:"oneone"},{Result:"two"},{Result:"three"})

>> Concatenate(["one", "two"], ["hello", Mid("great", -1), "world"])
Table({Result:"onehello"},{Result:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{Result:"world"})
Table({Result:"onehello"},{Result:Microsoft.PowerFx.Types.ErrorValue},{Result:"world"})

>> Concatenate(["a","b","c","d"], "-", ["1", "2"], "-", ["x", "y", "z"], "!")
Table({Result:"a-1-x!"},{Result:"b-2-y!"},{Result:"c--z!"},{Result:"d--!"})
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
Table({a:0},{a:0.5},{a:1})

>> Sin(Table({a:0},{a:1/0},{a:Pi()/2}))
Table({a:0},{a:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{a:1})
Table({a:0},{a:Microsoft.PowerFx.Types.ErrorValue},{a:1})

>> Sin(Table({a:0},{a:Pi()/6},If(1/0<2,{a:Pi()})))
Table({a:0},{a:0.5},Microsoft.PowerFx.Core.Public.Values.ErrorValue)
Table({a:0},{a:0.5},Microsoft.PowerFx.Types.ErrorValue)

>> Round(Sin([0, Pi(), Pi()/2, -Pi()/2, 3*Pi()/2, 2*Pi(), Pi()/4, -Pi()/4, Blank()]), 4)
[0, 0, 1, -1, -1, -0, 0.7071, -0.7071, 0]
Expand All @@ -14,10 +14,10 @@ Table({a:0},{a:0.5},Microsoft.PowerFx.Core.Public.Values.ErrorValue)
Table({a:1},{a:0.5},{a:0})

>> Cos(Table({a:1/0},{a:Pi()/3},{a:Pi()/2}))
Table({a:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{a:0.5},{a:0})
Table({a:Microsoft.PowerFx.Types.ErrorValue},{a:0.5},{a:0})

>> Cos(Table({a:0},If(1/0<2,{a:Pi()/3}),{a:Pi()/2}))
Table({a:1},Microsoft.PowerFx.Core.Public.Values.ErrorValue,{a:0})
Table({a:1},Microsoft.PowerFx.Types.ErrorValue,{a:0})

>> Round(Cos([0, Pi(), Pi()/2, -Pi()/2, 3*Pi()/2, 2*Pi(), Pi()/4, -Pi()/4, Blank()]), 4)
[1, -1, 0, 0, -0, 1, 0.7071, 0.7071, 1]
Expand All @@ -26,10 +26,10 @@ Table({a:1},Microsoft.PowerFx.Core.Public.Values.ErrorValue,{a:0})
Table({a:0},{a:1},{a:-1})

>> Tan(Table({a:1/0},{a:Pi()/4},{a:-Pi()/4}))
Table({a:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{a:1},{a:-1})
Table({a:Microsoft.PowerFx.Types.ErrorValue},{a:1},{a:-1})

>> Tan(Table(If(1/0<2,{a:0}),{a:Pi()/4},{a:-Pi()/4}))
Table(Microsoft.PowerFx.Core.Public.Values.ErrorValue,{a:1},{a:-1})
Table(Microsoft.PowerFx.Types.ErrorValue,{a:1},{a:-1})

>> Round(Tan([0, Pi(), 2*Pi(), Pi()/4, -Pi()/4, Blank()]), 4)
[0, -0, -0, 1, -1, 0]
Expand All @@ -38,10 +38,10 @@ Table(Microsoft.PowerFx.Core.Public.Values.ErrorValue,{a:1},{a:-1})
Table({a:0},{a:1},{a:-1})

>> Cot(Table({a:Pi()/2},{a:0},{a:-Pi()/4}))
Table({a:0},{a:Microsoft.PowerFx.Core.Public.Values.ErrorValue},{a:-1})
Table({a:0},{a:Microsoft.PowerFx.Types.ErrorValue},{a:-1})

>> Cot(Table({a:Pi()/2},If(Sqrt(-1)<1,{a:Pi()/4}),{a:-Pi()/4}))
Table({a:0},Microsoft.PowerFx.Core.Public.Values.ErrorValue,{a:-1})
Table({a:0},Microsoft.PowerFx.Types.ErrorValue,{a:-1})

>> Round(Cot([Pi()/2, -Pi()/2, 3*Pi()/2, Pi()/4, -Pi()/4]), 4)
[0, -0, 0, 1, -1]
Expand Down
4 changes: 2 additions & 2 deletions src/tests/Microsoft.PowerFx.Core.Tests/PublicSurfaceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ public void Test()
"Microsoft.PowerFx.ErrorKind",
"Microsoft.PowerFx.ExpressionError",
"Microsoft.PowerFx.FormulaWithParameters",
"Microsoft.PowerFx.Core.Public.IExpression",
"Microsoft.PowerFx.Core.Public.IExpressionExtensions",
"Microsoft.PowerFx.IExpression",
"Microsoft.PowerFx.IExpressionExtensions",
"Microsoft.PowerFx.IPowerFxEngine",
"Microsoft.PowerFx.ParserOptions",
"Microsoft.PowerFx.Engine",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ public void PublicSurfaceTests()
var asm = typeof(RecalcEngine).Assembly;

var ns = "Microsoft.PowerFx";
var nsType = "Microsoft.PowerFx.Types";
var allowed = new HashSet<string>()
{
$"{ns}.{nameof(RecalcEngine)}",
$"{ns}.{nameof(ReflectionFunction)}",
$"{ns}.{nameof(RecalcEngineScope)}",
$"{ns}.{nameof(PowerFxConfigExtensions)}",
$"{ns}.{nameof(OptionSet)}",
$"{ns}.{nameof(ObjectRecordValue)}",
$"{ns}.{nameof(ITypeMarshallerProvider)}",
$"{ns}.{nameof(ITypeMarshaller)}",
$"{ns}.{nameof(OptionSet)}",
Expand All @@ -43,7 +43,8 @@ public void PublicSurfaceTests()
$"{ns}.{nameof(PrimitiveTypeMarshaller)}",
$"{ns}.{nameof(TableMarshallerProvider)}",
$"{ns}.{nameof(TypeMarshallerCache)}",
$"{ns}.{nameof(TypeMarshallerCacheExtensions)}"
$"{ns}.{nameof(TypeMarshallerCacheExtensions)}",
$"{nsType}.{nameof(ObjectRecordValue)}"
};

var sb = new StringBuilder();
Expand Down

0 comments on commit 9b90c21

Please sign in to comment.