@@ -2052,6 +2052,70 @@ class PipelineIntegrationTests: FSTIntegrationTestCase {
20522052 TestHelper . compare ( pipelineSnapshot: snapshot, expected: expectedResults, enforceOrder: true )
20532053 }
20542054
2055+ func testExpWorks( ) async throws {
2056+ let collRef = collectionRef ( withDocuments: [
2057+ " doc1 " : [ " value " : 1 ] ,
2058+ " doc2 " : [ " value " : 0 ] ,
2059+ " doc3 " : [ " value " : - 1 ] ,
2060+ ] )
2061+ let db = collRef. firestore
2062+
2063+ let pipeline = db. pipeline ( )
2064+ . collection ( collRef. path)
2065+ . select ( [
2066+ Field ( " value " ) . exp ( ) . as ( " expValue " ) ,
2067+ ] )
2068+ . sort ( [ Field ( " expValue " ) . ascending ( ) ] )
2069+
2070+ let snapshot = try await pipeline. execute ( )
2071+
2072+ let expectedResults : [ [ String : Sendable ] ] = [
2073+ [ " expValue " : Foundation . exp ( Double ( - 1 ) ) ] ,
2074+ [ " expValue " : Foundation . exp ( Double ( 0 ) ) ] ,
2075+ [ " expValue " : Foundation . exp ( Double ( 1 ) ) ] ,
2076+ ]
2077+
2078+ TestHelper . compare ( pipelineSnapshot: snapshot, expected: expectedResults, enforceOrder: true )
2079+ }
2080+
2081+ func testExpUnderflow( ) async throws {
2082+ let collRef = collectionRef ( withDocuments: [
2083+ " doc1 " : [ " value " : - 1000 ] ,
2084+ ] )
2085+ let db = collRef. firestore
2086+
2087+ let pipeline = db. pipeline ( )
2088+ . collection ( collRef. path)
2089+ . select ( [
2090+ Field ( " value " ) . exp ( ) . as ( " expValue " ) ,
2091+ ] )
2092+
2093+ let snapshot = try await pipeline. execute ( )
2094+
2095+ let expectedResults : [ [ String : Sendable ] ] = [
2096+ [ " expValue " : 0 ] ,
2097+ ]
2098+
2099+ TestHelper . compare ( pipelineSnapshot: snapshot, expected: expectedResults, enforceOrder: true )
2100+ }
2101+
2102+ func testExpOverflow( ) async throws {
2103+ let collRef = collectionRef ( withDocuments: [
2104+ " doc1 " : [ " value " : 1000 ] ,
2105+ ] )
2106+ let db = collRef. firestore
2107+
2108+ let pipeline = db. pipeline ( )
2109+ . collection ( collRef. path)
2110+ . select ( [
2111+ Field ( " value " ) . exp ( ) . as ( " expValue " ) ,
2112+ ] )
2113+
2114+ let snapshot = try await pipeline. execute ( )
2115+ XCTAssertEqual ( snapshot. results. count, 1 )
2116+ XCTAssertNil ( snapshot. results. first!. get ( " expValue " ) )
2117+ }
2118+
20552119 func testCollectionIdWorks( ) async throws {
20562120 let collRef = collectionRef ( )
20572121 let docRef = collRef. document ( " doc " )
0 commit comments