Exemplo n.º 1
0
# Tests for dict
if 1:
    d = {}
    d[0] = "zero"
    d["one"] = 1
    print d
    print dict.keys(d)
    print dict.values(d)

    dict.clear(d)
    print d
    d['new'] = "more"
    print d

    print "d has key 'new' = ", dict.has_key(d, 'new')
    print "d has key 'old' = ", dict.has_key(d, 'old')


# Tests for list
if 1:
    foo = [0]
    list.append(foo, 1)
    print foo

    list.extend(foo, [2, 2])
    print foo


    print list.count(foo, 1)
    print list.count(foo, 2)
Exemplo n.º 2
0
# This file is Copyright 2010 Dean Hall.
#
# This file is part of the Python-on-a-Chip program.
# Python-on-a-Chip is free software: you can redistribute it and/or modify
# it under the terms of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1.
#
# Python-on-a-Chip is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# A copy of the GNU LESSER GENERAL PUBLIC LICENSE Version 2.1
# is seen in the file COPYING up one directory from this.

#
# System Test 377
#

import dict


d = {0:None}

r1 = dict.has_key(d, 0)
r2 = dict.has_key(d, None)

# Must use "is" because 0 == False and 1 == True
assert r1 is True
assert r2 is False
Exemplo n.º 3
0
# Tests for dict
if 1:
    d = {}
    d[0] = "zero"
    d["one"] = 1
    print d
    print dict.keys(d)
    print dict.values(d)

    dict.clear(d)
    print d
    d['new'] = "more"
    print d

    print "d has key 'new' = ", dict.has_key(d, 'new')
    print "d has key 'old' = ", dict.has_key(d, 'old')


# Tests for list
if 1:
    foo = [0]
    list.append(foo, 1)
    print foo

    list.extend(foo, [2, 2])
    print foo


    print list.count(foo, 1)
    print list.count(foo, 2)
Exemplo n.º 4
0
# Tests for dict
if 1:
    d = {}
    d[0] = "zero"
    d["one"] = 1
    print d
    print dict.keys(d)
    print dict.values(d)

    dict.clear(d)
    print d
    d["new"] = "more"
    print d

    print "d has key 'new' = ", dict.has_key(d, "new")
    print "d has key 'old' = ", dict.has_key(d, "old")


# Tests for list
if 1:
    foo = [0]
    list.append(foo, 1)
    print foo

    list.extend(foo, [2, 2])
    print foo

    print list.count(foo, 1)
    print list.count(foo, 2)
    print list.count(foo, 42)