// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
import type { Range, SemVer } from "./types.ts";
import { satisfies } from "./satisfies.ts";

/**
 * Test to see if the version satisfies the range.
 *
 * @example Usage
 * ```ts
 * import { parse, parseRange, testRange } from "@std/semver";
 * import { assert, assertFalse } from "@std/assert";
 *
 * const version = parse("1.2.3");
 * const range0 = parseRange(">=1.0.0 <2.0.0");
 * const range1 = parseRange(">=1.0.0 <1.3.0");
 * const range2 = parseRange(">=1.0.0 <1.2.3");
 *
 * assert(testRange(version, range0));
 * assert(testRange(version, range1));
 * assertFalse(testRange(version, range2));
 * ```
 * @param version The version to test
 * @param range The range to check
 * @returns true if the version is in the range
 *
 * @deprecated This will be removed in 1.0.0. Use {@linkcode satisfies}
 * instead. See https://github.com/denoland/deno_std/pull/4364.
 */
export function testRange(version: SemVer, range: Range): boolean {
  return satisfies(version, range);
}

// denoCacheMetadata={"headers":{"cross-origin-resource-policy":"cross-origin","access-control-expose-headers":"*","x-content-type-options":"nosniff","content-length":"1055","server":"cloudflare","content-type":"text/typescript","cf-ray":"a223e657ca6c7db6-LAX","accept-ranges":"bytes","set-cookie":"__cf_bm=8ElpqvYfQtv_V56060AWxGzjEBaN8fp_mjYmN2PuTOg-1785241875.1623268-1.0.1.1-LnBdrBvXTd8Sw9hSj.noV6IVmp8ilK62_oD1y7al28IdLlH3lXmq1dfifyBglKn7226v2dfSC5Z0xJ4ewFc0K0DASBBaFO1S8H_1dhnJFGl5M.TcQk.Su3MWrq21Ye8e; HttpOnly; SameSite=None; Secure; Path=/; Domain=jsr.io; Expires=Tue, 28 Jul 2026 13:01:15 GMT","report-to":"{\"group\":\"cf-nel\",\"max_age\":604800,\"endpoints\":[{\"url\":\"https://a.nel.cloudflare.com/report/v4?s=3jnqZ%2F5zuIdyF%2B1NXpD32Eh7goIRQMg2Fv49YxodBr4pc5WIq%2BBraTg2V012cAveYBobYM6%2F0mJgSuz6w%2F5rdgGhPGKQPFdoiUaLoVYphH%2FOAZLk%2BQ6RJDw%3D\"}]}","vary":"Origin","cf-cache-status":"HIT","x-jsr-backend":"modules","alt-svc":"h3=\":443\"; ma=86400","date":"Tue, 28 Jul 2026 12:31:15 GMT","age":"36703","access-control-allow-origin":"*","content-security-policy":"default-src 'none'; script-src 'none'; style-src 'none'; img-src 'none'; font-src 'none'; connect-src 'none'; frame-src 'none'; object-src 'none'; frame-ancestors 'none'; sandbox; form-action 'none';","x-robots-tag":"noindex","cache-control":"public, max-age=31536000, immutable","etag":"\"68d435b66adbf03f9e49c2a9f01363db\"","nel":"{\"report_to\":\"cf-nel\",\"success_fraction\":0.0,\"max_age\":604800}"},"url":"https://jsr.io/@std/semver/0.224.3/test_range.ts","time":1785241875}