Removing duplication between pre-V1 and V1 tests.
This commit is contained in:
Carlos Figueira 2024-11-01 13:48:34 -07:00 коммит произвёл GitHub
Родитель e1e538183a
Коммит 6089c04966
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
11 изменённых файлов: 206 добавлений и 231 удалений

Просмотреть файл

@ -1,21 +0,0 @@
#SETUP: disable:SupportColumnNamesAsIdentifiers
#SETUP: disable:NumberIsFloat
#SETUP: DecimalSupport
// DV Decimal: These tests are compabtible with the SQL compiler used by Dataverse, with a max/min of +/-100,000,000,000 and ten decimal places.
// Variants of 10000000000.0000000001 are used which is not representable in floating point (rounds to 10000000000).
// These tests are also runnable with the C# semantics for decimal which is why they are included in the Power-Fx repo, ensuring consistency between DV and C#.
// Where possible, unless specifically testing the C# range, should be written in the DV rnage.
>> AddColumns(["1","2","3"],"dec",Decimal(Value)+10000000000.0000000007)
Table({Value:"1",dec:10000000001.0000000007},{Value:"2",dec:10000000002.0000000007},{Value:"3",dec:10000000003.0000000007})
>> AddColumns(["1","2","3"],"dec",Value+10000000000.0000000007)
Table({Value:"1",dec:10000000001.0000000007},{Value:"2",dec:10000000002.0000000007},{Value:"3",dec:10000000003.0000000007})
>> AddColumns(["1","2","3"],"dec",Float(Value)+10000000000.0000000007)
Table({Value:"1",dec:10000000001},{Value:"2",dec:10000000002},{Value:"3",dec:10000000003})
>> AddColumns(["1","2","3"],"dec",Value(Value)+10000000000.0000000007)
Table({Value:"1",dec:10000000001.0000000007},{Value:"2",dec:10000000002.0000000007},{Value:"3",dec:10000000003.0000000007})

Просмотреть файл

@ -1,17 +0,0 @@
#SETUP: disable:PowerFxV1CompatibilityRules,ConsistentOneColumnTableResult,TableSyntaxDoesntWrapRecords
>> Last([ {a:2}, {a:true, b:true, c:20}, {a:2, b:2, c:true} ]).c
true
// Without PowerFxV1CompatibilityRules feature, the following coercions will fail
>> Len(GUID())
Error({Kind:ErrorKind.InvalidArgument})
>> GUID() & GUID() <> ""
Error(Table({Kind:ErrorKind.InvalidArgument},{Kind:ErrorKind.InvalidArgument}))
>> Len(Lower(GUID()))
Error({Kind:ErrorKind.InvalidArgument})
>> Len(GUID() & GUID())
Error(Table({Kind:ErrorKind.InvalidArgument},{Kind:ErrorKind.InvalidArgument}))

Просмотреть файл

@ -51,3 +51,121 @@ Errors: Error 0-14: Invalid argument type. Expecting one of the following: Boole
>> If(Date(2000,1,1),1,2)
Errors: Error 3-17: Invalid argument type (Date). Expecting a Boolean value instead.
// ************** Coercions between date/time values **************
>> If(1<0, DateTime(2000,1,1,1,1,1), Time(12,34,56,789))
DateTime(1899,12,30,12,34,56,789)
>> If(1<0, DateTime(2000,1,1,1,1,1), Date(2023,3,27))
DateTime(2023,3,27,0,0,0,0)
>> If(1<0, Time(1,2,3), Date(2000,1,1))
Time(0,0,0,0)
>> If(1<0, Date(2000,1,1), Time(12,0,0))
Date(1899,12,30)
>> If(1<0, Time(1,2,3), DateTime(2000,1,1,12,34,56,789))
Time(12,34,56,789)
>> If(1<0, Date(2000,1,1), DateTime(2134,5,6,12,0,0))
Date(2134,5,6)
// ************** Blank value coercion **************
// Boolean to number
>> If(1<0, 1, If(1<0,false))
Blank()
// Boolean to text
>> If(1<0, "A", If(1<0,false))
Blank()
// Number to boolean
>> If(1<0, 1, If(1<0,1))
Blank()
// Number to text
>> If(1<0, "A", If(1<0,1))
Blank()
// Number to datetime
>> If(1<0, DateTime(2023,1,1,3,4,5), If(1<0,1))
Blank()
// Number to date
>> If(1<0, Date(2023,1,1), If(1<0,1))
Blank()
// Number to time
>> If(1<0, Time(1,2,3), If(1<0,1))
Blank()
// Text to booleam
>> If(1<0, false, If(1<0,"a"))
Blank()
// Text to number
>> If(1<0, 1, If(1<0,"a"))
Blank()
// Text to datetime
>> If(1<0, DateTime(2023,1,1,3,4,5), If(1<0,"a"))
Blank()
// Text to date
>> If(1<0, Date(2023,1,1), If(1<0,"a"))
Blank()
// Text to time
>> If(1<0, Time(1,2,3), If(1<0,"a"))
Blank()
// Date to number
>> If(1<0, 1, If(1<0,Date(2000,1,1)))
Blank()
// Date to text
>> If(1<0, "A", If(1<0,Date(2000,1,1)))
Blank()
// Date to datetime
>> If(1<0, DateTime(2023,1,1,3,4,5), If(1<0,Date(2000,1,1)))
Blank()
// Date to time
>> If(1<0, Time(1,2,3), If(1<0,Date(2000,1,1)))
Blank()
// DateTime to number
>> If(1<0, 1, If(1<0,DateTime(2023,1,1,3,4,5)))
Blank()
// DateTime to text
>> If(1<0, "A", If(1<0,DateTime(2023,1,1,3,4,5)))
Blank()
// DateTime to date
>> If(1<0, Date(2023,1,1), If(1<0,DateTime(2023,1,1,3,4,5)))
Blank()
// DateTime to time
>> If(1<0, Time(1,2,3), If(1<0,DateTime(2023,1,1,3,4,5)))
Blank()
// Time to number
>> If(1<0, 1, If(1<0,Time(1,2,3)))
Blank()
// Time to text
>> If(1<0, "A", If(1<0,Time(1,2,3)))
Blank()
// Time to datetime
>> If(1<0, DateTime(2023,1,1,3,4,5), If(1<0,Time(1,2,3)))
Blank()
// Time to date
>> If(1<0, Date(2023,1,1), If(1<0,Time(1,2,3)))
Blank()

Просмотреть файл

@ -1,123 +0,0 @@
#SETUP: PowerFxV1CompatibilityRules
>> GUID("AAAAAAAA-BBBB-CCCC-DDDD-EEEEFFFFFFFF") & " is a GUID"
"aaaaaaaa-bbbb-cccc-dddd-eeeeffffffff is a GUID"
>> If(1<0, GUID("AAAAAAAA-BBBB-CCCC-DDDD-EEEEFFFFFFFF"), "11111111-2222-3333-4444-555566666666")
GUID("11111111-2222-3333-4444-555566666666")
>> If(1<0, Time(1,2,3), Date(2000,1,1))
Time(0,0,0,0)
>> If(1<0, Time(1,2,3), DateTime(2000,1,1,12,34,56,789))
Time(12,34,56,789)
>> If(1<0, Date(2000,1,1), Time(12,0,0))
Date(1899,12,30)
>> If(1<0, Date(2000,1,1), DateTime(2134,5,6,12,0,0))
Date(2134,5,6)
>> If(1<0, DateTime(2000,1,1,1,1,1), Time(12,34,56,789))
DateTime(1899,12,30,12,34,56,789)
>> If(1<0, DateTime(2000,1,1,1,1,1), Date(2023,3,27))
DateTime(2023,3,27,0,0,0,0)
// ************** Blank value coercion **************
// Boolean to number
>> If(1<0, 1, If(1<0,false))
Blank()
// Boolean to text
>> If(1<0, "A", If(1<0,false))
Blank()
// Number to boolean
>> If(1<0, 1, If(1<0,1))
Blank()
// Number to text
>> If(1<0, "A", If(1<0,1))
Blank()
// Number to datetime
>> If(1<0, DateTime(2023,1,1,3,4,5), If(1<0,1))
Blank()
// Number to date
>> If(1<0, Date(2023,1,1), If(1<0,1))
Blank()
// Number to time
>> If(1<0, Time(1,2,3), If(1<0,1))
Blank()
// Text to booleam
>> If(1<0, false, If(1<0,"a"))
Blank()
// Text to number
>> If(1<0, 1, If(1<0,"a"))
Blank()
// Text to datetime
>> If(1<0, DateTime(2023,1,1,3,4,5), If(1<0,"a"))
Blank()
// Text to date
>> If(1<0, Date(2023,1,1), If(1<0,"a"))
Blank()
// Text to time
>> If(1<0, Time(1,2,3), If(1<0,"a"))
Blank()
// Date to number
>> If(1<0, 1, If(1<0,Date(2000,1,1)))
Blank()
// Date to text
>> If(1<0, "A", If(1<0,Date(2000,1,1)))
Blank()
// Date to datetime
>> If(1<0, DateTime(2023,1,1,3,4,5), If(1<0,Date(2000,1,1)))
Blank()
// Date to time
>> If(1<0, Time(1,2,3), If(1<0,Date(2000,1,1)))
Blank()
// DateTime to number
>> If(1<0, 1, If(1<0,DateTime(2023,1,1,3,4,5)))
Blank()
// DateTime to text
>> If(1<0, "A", If(1<0,DateTime(2023,1,1,3,4,5)))
Blank()
// DateTime to date
>> If(1<0, Date(2023,1,1), If(1<0,DateTime(2023,1,1,3,4,5)))
Blank()
// DateTime to time
>> If(1<0, Time(1,2,3), If(1<0,DateTime(2023,1,1,3,4,5)))
Blank()
// Time to number
>> If(1<0, 1, If(1<0,Time(1,2,3)))
Blank()
// Time to text
>> If(1<0, "A", If(1<0,Time(1,2,3)))
Blank()
// Time to datetime
>> If(1<0, DateTime(2023,1,1,3,4,5), If(1<0,Time(1,2,3)))
Blank()
// Time to date
>> If(1<0, Date(2023,1,1), If(1<0,Time(1,2,3)))
Blank()

Просмотреть файл

@ -1,25 +0,0 @@
#SETUP: disable:PowerFxV1CompatibilityRules
>> GUID("AAAAAAAA-BBBB-CCCC-DDDD-EEEEFFFFFFFF") & " is a GUID"
"aaaaaaaa-bbbb-cccc-dddd-eeeeffffffff is a GUID"
>> If(1<0, GUID("AAAAAAAA-BBBB-CCCC-DDDD-EEEEFFFFFFFF"), "11111111-2222-3333-4444-555566666666")
"11111111-2222-3333-4444-555566666666"
>> If(1<0, Time(1,2,3), Date(2000,1,1))
DateTime(2000,1,1,0,0,0,0)
>> If(1<0, Time(1,2,3), DateTime(2000,1,1,12,34,56,789))
DateTime(2000,1,1,12,34,56,789)
>> If(1<0, Date(2000,1,1), Time(12,0,0))
DateTime(1899,12,30,12,0,0,0)
>> If(1<0, Date(2000,1,1), DateTime(2134,5,6,12,0,0))
DateTime(2134,5,6,12,0,0,0)
>> If(1<0, DateTime(2000,1,1,1,1,1), Time(12,34,56,789))
DateTime(1899,12,30,12,34,56,789)
>> If(1<0, DateTime(2000,1,1,1,1,1), Date(2023,3,27))
DateTime(2023,3,27,0,0,0,0)

Просмотреть файл

@ -272,3 +272,18 @@ DateTime(2022,8,7,12,34,56,0)
// This may not work in different locales
>> Coalesce("",DateTime(2022,1,2,6,30,0))
"1/2/2022 6:30 AM"
>> Coalesce(If(1<0,1), IfError(If(1<0,2),22), 3)
3
>> Coalesce("", Blank(), If(1<0,IfError("c","c")), IfError("d","d"))
"d"
>> Coalesce(1, 2, 3, 4)
1
>> Coalesce(If(1<0,false), If(1<0,true), false, true)
false
>> Coalesce(If(1<0,false), If(1<0,true), true)
true

Просмотреть файл

@ -105,3 +105,27 @@ false
>> "jOHN" exactin ["Jane", "John"]
false
>> "a" in Blank()
false
>> "a" exactin Blank()
false
>> "" in Blank()
true
>> "" exactin Blank()
true
>> Blank() in Blank()
true
>> Blank() exactin Blank()
true
>> Blank() in "hello"
true
>> Blank() exactin "hello"
true

Просмотреть файл

@ -1,29 +0,0 @@
#SETUP: PowerFxV1CompatibilityRules
// In (Case insensitive), ExactIn (case sensitive)
// Scalar, Table forms.
// https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/operators#in-and-exactin-operators
>> "a" in Blank()
false
>> "a" exactin Blank()
false
>> "" in Blank()
true
>> "" exactin Blank()
true
>> Blank() in Blank()
true
>> Blank() exactin Blank()
true
>> Blank() in "hello"
true
>> Blank() exactin "hello"
true

Просмотреть файл

@ -1,14 +0,0 @@
#SETUP: disable:PowerFxV1CompatibilityRules
// In (Case insensitive), ExactIn (case sensitive)
// Scalar, Table forms.
// https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/operators#in-and-exactin-operators
>> "a" in Blank()
false
>> "" in Blank()
true
>> Blank() in Blank()
true

Просмотреть файл

@ -1,10 +1,37 @@
#OVERRIDE: BasicCoercion_V1CompatDisabled.txt
#OVERRIDE: BasicCoercion.txt
#SETUP: disable:PowerFxV1CompatibilityRules
// Bug in pre-V1, fixed in V1
>> GUID("AAAAAAAA-BBBB-CCCC-DDDD-EEEEFFFFFFFF") & " is a GUID"
#skip
>> If(1<0, GUID("AAAAAAAA-BBBB-CCCC-DDDD-EEEEFFFFFFFF"), "11111111-2222-3333-4444-555566666666")
"11111111-2222-3333-4444-555566666666"
// Before V1, mixing Time/Date would result in DateTime
>> If(1<0, Time(1,2,3), DateTime(2000,1,1,12,34,56,789))
DateTime(2000,1,1,12,34,56,789)
// Before V1, mixing Time/Date would result in DateTime
>> If(1<0, Date(2000,1,1), DateTime(2134,5,6,12,0,0))
DateTime(2134,5,6,12,0,0,0)
// Bug in pre-V1, fixed in V1
>> If(1<0, DateTime(2023,1,1,3,4,5), If(1<0,Date(2000,1,1)))
#skip
// Bug in pre-V1, fixed in V1
>> If(1<0, Time(1,2,3), If(1<0,Date(2000,1,1)))
#skip
// Bug in pre-V1, fixed in V1
>> If(1<0, DateTime(2023,1,1,3,4,5), If(1<0,Time(1,2,3)))
#skip
// Bug in pre-V1, fixed in V1
>> If(1<0, Date(2023,1,1), If(1<0,Time(1,2,3)))
#skip
// Bug in pre-V1, fixed in V1
>> If(1<0, DateTime(2000,1,1,1,1,1), Time(12,34,56,789))
#skip

Просмотреть файл

@ -1,14 +1,34 @@
#OVERRIDE: inScalar_V1CompatDisabled.txt
#OVERRIDE: inScalar.txt
#SETUP: disable:PowerFxV1CompatibilityRules
// Bug in pre-V1, fixed in V1
>> "a" in Blank()
#skip
// Bug in pre-V1, fixed in V1
>> "a" exactin Blank()
#skip
// Bug in pre-V1, fixed in V1
>> "" in Blank()
#skip
// Bug in pre-V1, fixed in V1
>> "" exactin Blank()
#skip
// Bug in pre-V1, fixed in V1
>> Blank() in Blank()
#skip
// Bug in pre-V1, fixed in V1
>> Blank() exactin Blank()
#skip
// Bug in pre-V1, fixed in V1
>> Blank() in "hello"
#skip
// Bug in pre-V1, fixed in V1
>> Blank() exactin "hello"
#skip