@@ -12,6 +12,20 @@ describe('JSON.SET', () => {
1212 ) ;
1313 } ) ;
1414
15+ it ( 'condition NX' , ( ) => {
16+ assert . deepEqual (
17+ parseArgs ( SET , 'key' , '$' , 'json' , { condition : 'NX' } ) ,
18+ [ 'JSON.SET' , 'key' , '$' , '"json"' , 'NX' ]
19+ ) ;
20+ } ) ;
21+
22+ it ( 'condition XX' , ( ) => {
23+ assert . deepEqual (
24+ parseArgs ( SET , 'key' , '$' , 'json' , { condition : 'XX' } ) ,
25+ [ 'JSON.SET' , 'key' , '$' , '"json"' , 'XX' ]
26+ ) ;
27+ } ) ;
28+
1529 it ( 'NX' , ( ) => {
1630 assert . deepEqual (
1731 parseArgs ( SET , 'key' , '$' , 'json' , { NX : true } ) ,
@@ -25,6 +39,22 @@ describe('JSON.SET', () => {
2539 [ 'JSON.SET' , 'key' , '$' , '"json"' , 'XX' ]
2640 ) ;
2741 } ) ;
42+
43+ for ( const fpha of [ 'BF16' , 'FP16' , 'FP32' , 'FP64' ] as const ) {
44+ it ( `FPHA ${ fpha } ` , ( ) => {
45+ assert . deepEqual (
46+ parseArgs ( SET , 'key' , '$' , 'json' , { fpha } ) ,
47+ [ 'JSON.SET' , 'key' , '$' , '"json"' , 'FPHA' , fpha ]
48+ ) ;
49+ } ) ;
50+ }
51+
52+ it ( 'condition with FPHA' , ( ) => {
53+ assert . deepEqual (
54+ parseArgs ( SET , 'key' , '$' , 'json' , { condition : 'NX' , fpha : 'FP32' } ) ,
55+ [ 'JSON.SET' , 'key' , '$' , '"json"' , 'NX' , 'FPHA' , 'FP32' ]
56+ ) ;
57+ } ) ;
2858 } ) ;
2959
3060 testUtils . testWithClient ( 'client.json.set' , async client => {
@@ -33,4 +63,37 @@ describe('JSON.SET', () => {
3363 'OK'
3464 ) ;
3565 } , GLOBAL . SERVERS . OPEN ) ;
66+
67+ testUtils . testWithClientIfVersionWithinRange ( [ [ 8 , 8 ] , 'LATEST' ] , 'client.json.set with FPHA' , async client => {
68+ const fpArray = [ 1.1 , 2.2 , 3.3 , 4.4 ] ;
69+
70+ for ( const fpha of [ 'FP32' , 'FP64' , 'FP16' , 'BF16' ] as const ) {
71+ const key = `fpha:${ fpha } ` ;
72+ assert . equal (
73+ await client . json . set ( key , '$' , fpArray , { fpha } ) ,
74+ 'OK'
75+ ) ;
76+
77+ const result = await client . json . get ( key ) ;
78+ assert . equal ( Array . isArray ( result ) , true ) ;
79+ assert . equal ( ( result as Array < unknown > ) . length , fpArray . length ) ;
80+ }
81+ } , GLOBAL . SERVERS . OPEN ) ;
82+
83+ testUtils . testWithClientIfVersionWithinRange ( [ [ 8 , 8 ] , 'LATEST' ] , 'client.json.set with FPHA and conditions' , async client => {
84+ const fpArray = [ 1.5 , 2.5 , 3.5 ] ;
85+
86+ assert . equal (
87+ await client . json . set ( 'fpha:nx' , '$' , fpArray , { condition : 'NX' , fpha : 'FP32' } ) ,
88+ 'OK'
89+ ) ;
90+ assert . equal (
91+ await client . json . set ( 'fpha:nx' , '$' , [ 4.5 , 5.5 ] , { condition : 'NX' , fpha : 'FP32' } ) ,
92+ null
93+ ) ;
94+ assert . equal (
95+ await client . json . set ( 'fpha:nx' , '$' , [ 4.5 , 5.5 ] , { condition : 'XX' , fpha : 'FP32' } ) ,
96+ 'OK'
97+ ) ;
98+ } , GLOBAL . SERVERS . OPEN ) ;
3699} ) ;
0 commit comments