mirror of
https://github.com/pacnpal/Roo-Code.git
synced 2025-12-20 20:31:37 -05:00
fix: update tests to handle new experimental diff option and increase the default confidence to 1
This commit is contained in:
@@ -7,14 +7,11 @@ import { NewUnifiedDiffStrategy } from './strategies/new-unified'
|
||||
* @param model The name of the model being used (e.g., 'gpt-4', 'claude-3-opus')
|
||||
* @returns The appropriate diff strategy for the model
|
||||
*/
|
||||
export function getDiffStrategy(model: string, fuzzyMatchThreshold?: number, experimentalDiffStrategy?: boolean): DiffStrategy {
|
||||
export function getDiffStrategy(model: string, fuzzyMatchThreshold?: number, experimentalDiffStrategy: boolean = false): DiffStrategy {
|
||||
if (experimentalDiffStrategy) {
|
||||
// Use the fuzzyMatchThreshold with a minimum of 0.8 (80%)
|
||||
const threshold = Math.max(fuzzyMatchThreshold ?? 1.0, 0.8)
|
||||
return new NewUnifiedDiffStrategy(threshold)
|
||||
return new NewUnifiedDiffStrategy(fuzzyMatchThreshold)
|
||||
}
|
||||
// Default to the stable SearchReplaceDiffStrategy
|
||||
return new SearchReplaceDiffStrategy()
|
||||
return new SearchReplaceDiffStrategy(fuzzyMatchThreshold)
|
||||
}
|
||||
|
||||
export type { DiffStrategy }
|
||||
|
||||
@@ -11,7 +11,7 @@ describe('main', () => {
|
||||
describe('constructor', () => {
|
||||
it('should use default confidence threshold when not provided', () => {
|
||||
const defaultStrategy = new NewUnifiedDiffStrategy()
|
||||
expect(defaultStrategy['confidenceThreshold']).toBe(0.9)
|
||||
expect(defaultStrategy['confidenceThreshold']).toBe(1)
|
||||
})
|
||||
|
||||
it('should use provided confidence threshold', () => {
|
||||
|
||||
@@ -6,8 +6,8 @@ import { DiffResult, DiffStrategy } from "../../types"
|
||||
export class NewUnifiedDiffStrategy implements DiffStrategy {
|
||||
private readonly confidenceThreshold: number
|
||||
|
||||
constructor(confidenceThreshold: number = 0.9) {
|
||||
this.confidenceThreshold = Math.max(confidenceThreshold, 0.8)
|
||||
constructor(confidenceThreshold: number = 1) {
|
||||
this.confidenceThreshold = Math.max(confidenceThreshold, 0.8);
|
||||
}
|
||||
|
||||
private parseUnifiedDiff(diff: string): Diff {
|
||||
|
||||
Reference in New Issue
Block a user