import { expect, test } from 'vitest'; import * as condition from './condition'; test.for([ { c: '', want: [], }, { c: 'all_corner_random==1', want: [[{ type: 'all_corner_random', op: '==', arg: 1 }]], }, { c: 'corner!=0', want: [[{ type: 'corner', op: '!=', arg: 0 }]], }, { c: 'order_rate<80', want: [[{ type: 'order_rate', op: '<', arg: 80 }]], }, { c: 'distance_diff_top<=5', want: [[{ type: 'distance_diff_top', op: '<=', arg: 5 }]], }, { c: 'motivation>=4', want: [[{ type: 'motivation', op: '>=', arg: 4 }]], }, { c: 'compete_fight_count>0', want: [[{ type: 'compete_fight_count', op: '>', arg: 0 }]], }, { c: 'phase==1&change_order_onetime<0', want: [ [ { type: 'phase', op: '==', arg: 1 }, { type: 'change_order_onetime', op: '<', arg: 0 }, ], ], }, { c: 'temptation_count==0&remain_distance<=201&remain_distance>=199&order>=4&order_rate<=70', want: [ [ { type: 'temptation_count', op: '==', arg: 0 }, { type: 'remain_distance', op: '<=', arg: 201 }, { type: 'remain_distance', op: '>=', arg: 199 }, { type: 'order', op: '>=', arg: 4 }, { type: 'order_rate', op: '<=', arg: 70 }, ], ], }, { c: 'track_id==10001@track_id==10002@track_id==10004@track_id==10010@track_id==10103@track_id==10104', want: [ [{ type: 'track_id', op: '==', arg: 10001 }], [{ type: 'track_id', op: '==', arg: 10002 }], [{ type: 'track_id', op: '==', arg: 10004 }], [{ type: 'track_id', op: '==', arg: 10010 }], [{ type: 'track_id', op: '==', arg: 10103 }], [{ type: 'track_id', op: '==', arg: 10104 }], ], }, { c: 'distance_type==1&phase>=2&order_rate>=50&is_overtake==1@distance_type==2&phase>=2&order_rate>=50&is_overtake==1', want: [ [ { type: 'distance_type', op: '==', arg: 1 }, { type: 'phase', op: '>=', arg: 2 }, { type: 'order_rate', op: '>=', arg: 50 }, { type: 'is_overtake', op: '==', arg: 1 }, ], [ { type: 'distance_type', op: '==', arg: 2 }, { type: 'phase', op: '>=', arg: 2 }, { type: 'order_rate', op: '>=', arg: 50 }, { type: 'is_overtake', op: '==', arg: 1 }, ], ], }, ])('$c', ({ c, want }) => expect(condition.parse(c)).toEqual(want));