Exemplo n.º 1
0
def comparison():
  # [version1, version2]
  # version1 should be greater than version2
  tests = [['0.0.0', '0.0.0-foo'],
    ['0.0.1', '0.0.0'],
    ['1.0.0', '0.9.9'],
    ['0.10.0', '0.9.0'],
    ['0.99.0', '0.10.0'],
    ['2.0.0', '1.2.3'],
    ['v0.0.0', '0.0.0-foo'],
    ['v0.0.1', '0.0.0'],
    ['v1.0.0', '0.9.9'],
    ['v0.10.0', '0.9.0'],
    ['v0.99.0', '0.10.0'],
    ['v2.0.0', '1.2.3'],
    ['0.0.0', 'v0.0.0-foo'],
    ['0.0.1', 'v0.0.0'],
    ['1.0.0', 'v0.9.9'],
    ['0.10.0', 'v0.9.0'],
    ['0.99.0', 'v0.10.0'],
    ['2.0.0', 'v1.2.3'],
    ['1.2.3', '1.2.3-asdf'],
    ['1.2.3', '1.2.3-4'],
    ['1.2.3', '1.2.3-4-foo'],
    ['1.2.3-5-foo', '1.2.3-5'],
    ['1.2.3-5', '1.2.3-4'],
    ['1.2.3-5-foo', '1.2.3-5-Foo'],
    ['3.0.0', '2.7.2+asdf'],
    ['1.2.3-a.10', '1.2.3-a.5'],
    ['1.2.3-a.b', '1.2.3-a.5'],
    ['1.2.3-a.b', '1.2.3-a'],
    ['1.2.3-a.b.c.10.d.5', '1.2.3-a.b.c.5.d.100']
  ]

  for v in tests:
    v0 = v[0]
    v1 = v[1]
    ok(gt(v0, v1), "gt('" + v0 + "', '" + v1 + "')")
    ok(lt(v1, v0), "lt('" + v1 + "', '" + v0 + "')")
    ok(not gt(v1, v0), "!gt('" + v1 + "', '" + v0 + "')")
    ok(not lt(v0, v1), "!lt('" + v0 + "', '" + v1 + "')")
    ok(eq(v0, v0), "eq('" + v0 + "', '" + v0 + "')")
    ok(eq(v1, v1), "eq('" + v1 + "', '" + v1 + "')")
    ok(ne(v0, v1), "ne('" + v0 + "', '" + v1 + "')")
Exemplo n.º 2
0
def equality():
  # [version1, version2]
  # version1 should be equivalent to version2
  tests = [['1.2.3', 'v1.2.3'],
    ['1.2.3', '=1.2.3'],
    ['1.2.3', 'v 1.2.3'],
    ['1.2.3', '= 1.2.3'],
    ['1.2.3', ' v1.2.3'],
    ['1.2.3', ' =1.2.3'],
    ['1.2.3', ' v 1.2.3'],
    ['1.2.3', ' = 1.2.3'],
    ['1.2.3-0', 'v1.2.3-0'],
    ['1.2.3-0', '=1.2.3-0'],
    ['1.2.3-0', 'v 1.2.3-0'],
    ['1.2.3-0', '= 1.2.3-0'],
    ['1.2.3-0', ' v1.2.3-0'],
    ['1.2.3-0', ' =1.2.3-0'],
    ['1.2.3-0', ' v 1.2.3-0'],
    ['1.2.3-0', ' = 1.2.3-0'],
    ['1.2.3-1', 'v1.2.3-1'],
    ['1.2.3-1', '=1.2.3-1'],
    ['1.2.3-1', 'v 1.2.3-1'],
    ['1.2.3-1', '= 1.2.3-1'],
    ['1.2.3-1', ' v1.2.3-1'],
    ['1.2.3-1', ' =1.2.3-1'],
    ['1.2.3-1', ' v 1.2.3-1'],
    ['1.2.3-1', ' = 1.2.3-1'],
    ['1.2.3-beta', 'v1.2.3-beta'],
    ['1.2.3-beta', '=1.2.3-beta'],
    ['1.2.3-beta', 'v 1.2.3-beta'],
    ['1.2.3-beta', '= 1.2.3-beta'],
    ['1.2.3-beta', ' v1.2.3-beta'],
    ['1.2.3-beta', ' =1.2.3-beta'],
    ['1.2.3-beta', ' v 1.2.3-beta'],
    ['1.2.3-beta', ' = 1.2.3-beta'],
    ['1.2.3-beta+build', ' = 1.2.3-beta+otherbuild'],
    ['1.2.3+build', ' = 1.2.3+otherbuild'],
    ['1.2.3-beta+build', '1.2.3-beta+otherbuild'],
    ['1.2.3+build', '1.2.3+otherbuild'],
    ['  v1.2.3+build', '1.2.3+otherbuild']
  ]

  for v in tests:
    v0 = v[0]
    v1 = v[1]
    ok(eq(v0, v1), "eq('" + v0 + "', '" + v1 + "')")
    ok(not ne(v0, v1), "!ne('" + v0 + "', '" + v1 + "')")
    ok(not gt(v0, v1), "!gt('" + v0 + "', '" + v1 + "')")
    ok(ge(v0, v1), "ge('" + v0 + "', '" + v1 + "')")
    ok(not lt(v0, v1), "!lt('" + v0 + "', '" + v1 + "')")
    ok(le(v0, v1), "le('" + v0 + "', '" + v1 + "')")
Exemplo n.º 3
0
def semver_min_satisfying(target_list, target_range):
    """
    Implementing the min_satisfying according to Node-Semver spec
    Obtaining the minimum/oldest version that satisfies target_range from the list
    """
    result_version = None
    user_filtered_list = semver_filter(target_list, target_range)

    for each_version in user_filtered_list:
        if result_version is None:
            result_version = each_version
        elif semver.gt(result_version, each_version, loose=True):
            result_version = each_version

    return result_version
Exemplo n.º 4
0
def test_gt(v0, v1, loose):
    from semver import gt
    assert not (gt(v0, v1, loose)) is True
Exemplo n.º 5
0
def test_ngt(v0, v1, loose):
    from semver import gt
    assert (not gt(v1, v0, loose)) is True
Exemplo n.º 6
0
def test_gt(v0, v1, loose):
    from semver import gt
    assert not (gt(v0, v1, loose)) is True
Exemplo n.º 7
0
def test_ngt(v0, v1, loose):
    from semver import gt
    assert (not gt(v1, v0, loose)) is True