How to use isSubClass method in Appium

Best JavaScript code snippet using appium

AllFunctions.jsx

Source:AllFunctions.jsx Github

copy

Full Screen

1export const functionsList = {2 getpoweroftwoceil: {3 javascript: `const get_power_of_two_ceil = (x) => {4 if (x <= 1) {5 return 16 } else if (x == 2) {7 return 28 } else {9 return 2 * get_power_of_two_ceil(Math.floor((x + 1) / 2))10 };11 };12 `,13 python: `def get_power_of_two_ceil(x):14 if x <= 1:15 return 116 elif x == 2:17 return 218 else:19 return 2 * get_power_of_two_ceil((x + 1) // 2)20 `,21 typescript: `function get_power_of_two_ceil(x: number): number {22 if (x <= 1) {23 return 124 } else if (x == 2) {25 return 226 } else {27 return 2 * get_power_of_two_ceil(Math.floor((x + 1) / 2))28 };29 };30 `,31 },32 getpoweroftwofloor: {33 python: `34 def get_power_of_two_floor(x: int) -> int:35 """36 Get the power of 2 for given input, or the closest lower power of 2 if the input is not a power of 2.37 The zero case is a placeholder and not used for math with generalized indices.38 Commonly used for "what power of two makes up the root bit of the generalized index?"39 Example: 0->1, 1->1, 2->2, 3->2, 4->4, 5->4, 6->4, 7->4, 8->8, 9->840 """41 if x <= 1:42 return 143 if x == 2:44 return x45 else:46 return 2 * get_power_of_two_floor(x // 2)47 `,48 javascript: `TODO`,49 typescript: `TODO`,50 },51 calculate_merkle_root: {52 python: `53def get_generalized_index(typ: SSZType, path: Sequence[Union[int, SSZVariableName]]) -> GeneralizedIndex:54 """55 Converts a path (eg. '[7, "foo", 3]' for 'x[7].foo[3]', '[12, "bar", "__len__"]' for56 'len(x[12].bar)') into the generalized index representing its position in the Merkle tree.57 """58 root = GeneralizedIndex(1)59 for p in path:60 assert not issubclass(typ, BasicValue) # If we descend to a basic type, the path cannot continue further61 if p == '__len__':62 typ = uint6463 assert issubclass(typ, (List, ByteList))64 root = GeneralizedIndex(root * 2 + 1)65 else:66 pos, _, _ = get_item_position(typ, p)67 base_index = (GeneralizedIndex(2) if issubclass(typ, (List, ByteList)) else GeneralizedIndex(1))68 root = GeneralizedIndex(root * base_index * get_power_of_two_ceil(chunk_count(typ)) + pos)69 typ = get_elem_type(typ, p)70 return root71`,72 },73 calculate_multi_merkle_root: {74 python: `75def calculate_merkle_root(leaf: Bytes32, proof: Sequence[Bytes32], index: GeneralizedIndex) -> Root:76 assert len(proof) == get_generalized_index_length(index)77 for i, h in enumerate(proof):78 if get_generalized_index_bit(index, i):79 leaf = hash(h + leaf)80 else:81 leaf = hash(leaf + h)82 return leaf83`,84javascript: "TODO"85 },86 chunk_count: {87 python: `88 def chunk_count(typ: SSZType) -> int:89 """90 Return the number of hashes needed to represent the top-level elements in the given type91 (eg. 'x.foo' or 'x[7]' but not 'x[7].bar' or 'x.foo.baz'). In all cases except lists/vectors92 of basic types, this is simply the number of top-level elements, as each element gets one93 hash. For lists/vectors of basic types, it is often fewer because multiple basic elements94 can be packed into one 32-byte chunk.95 """96 # typ.length describes the limit for list types, or the length for vector types.97 if issubclass(typ, BasicValue):98 return 199 elif issubclass(typ, Bits):100 return (typ.length + 255) // 256101 elif issubclass(typ, Elements):102 return (typ.length * item_length(typ.elem_type) + 31) // 32103 elif issubclass(typ, Container):104 return len(typ.get_fields())105 else:106 raise Exception(f"Type not supported: {typ}")107 `,108 javascript: `TODO`,109 typescript: `TODO`,110 },111 concat_general_indices: {112 python: `113 def concat_generalized_indices(*indices: GeneralizedIndex) -> GeneralizedIndex:114 """115 Given generalized indices i1 for A -> B, i2 for B -> C .... i_n for Y -> Z, returns116 the generalized index for A -> Z.117 """118 o = GeneralizedIndex(1)119 for i in indices:120 o = GeneralizedIndex(o * get_power_of_two_floor(i) + (i - get_power_of_two_floor(i)))121 return o122 `,123 javascript: `TODO`,124 typescript: `TODO`,125 },126 generalized_index_parent: {127 python: `128 def generalized_index_parent(index: GeneralizedIndex) -> GeneralizedIndex:129 return GeneralizedIndex(index // 2)130 `,131 javascript: `TODO`,132 typescript: `TODO`,133 },134 generalized_index_sibling: {135 python: `136 def generalized_index_sibling(index: GeneralizedIndex) -> GeneralizedIndex:137 return GeneralizedIndex(index ^ 1)138 `,139 javascript: `TODO`,140 typescript: `TODO`,141 },142 generlized_index_child: {143 python: `144 def generalized_index_child(index: GeneralizedIndex, right_side: bool) -> GeneralizedIndex:145 return GeneralizedIndex(index * 2 + right_side)146 `,147 javascript: `TODO`,148 typescript: `TODO`,149 },150 get_branch_indices: {151 python: `152 def get_branch_indices(tree_index: GeneralizedIndex) -> Sequence[GeneralizedIndex]:153 """154 Get the generalized indices of the sister chunks along the path from the chunk with the155 given tree index to the root.156 """157 o = [generalized_index_sibling(tree_index)]158 while o[-1] > 1:159 o.append(generalized_index_sibling(generalized_index_parent(o[-1])))160 return o[:-1]161 `,162 javascript: `TODO`,163 typescript: `TODO`,164 },165 get_elem_type: {166 python: `167 def get_elem_type(typ: Union[BaseBytes, BaseList, Container],168 index_or_variable_name: Union[int, SSZVariableName]) -> SSZType:169 """170 Return the type of the element of an object of the given type with the given index171 or member variable name (eg. '7' for 'x[7]', "foo" for 'x.foo')172 """173 return typ.get_fields()[index_or_variable_name] if issubclass(typ, Container) else typ.elem_type174 `,175 javascript: `TODO`,176 typescript: `TODO`,177 },178 get_generalized_index_bit: {179 python: `180 def get_generalized_index_bit(index: GeneralizedIndex, position: int) -> bool:181 """182 Return the given bit of a generalized index.183 """184 return (index & (1 << position)) > 0185 `,186 javascript: `TODO`,187 typescript: `TODO`,188 },189 get_generalized_index: {190 python: `191 def get_generalized_index_length(index: GeneralizedIndex) -> int:192 """193 Return the length of a path represented by a generalized index.194 """195 return int(log2(index))196 `,197 javascript: `TODO`,198 typescript: `TODO`,199 },200 // get_generalized_length: ,201 get_helper_indices: {202 python: `203 def get_helper_indices(indices: Sequence[GeneralizedIndex]) -> Sequence[GeneralizedIndex]:204 """205 Get the generalized indices of all "extra" chunks in the tree needed to prove the chunks with the given206 generalized indices. Note that the decreasing order is chosen deliberately to ensure equivalence to the207 order of hashes in a regular single-item Merkle proof in the single-item case.208 """209 all_helper_indices: Set[GeneralizedIndex] = set()210 all_path_indices: Set[GeneralizedIndex] = set()211 for index in indices:212 all_helper_indices = all_helper_indices.union(set(get_branch_indices(index)))213 all_path_indices = all_path_indices.union(set(get_path_indices(index)))214 return sorted(all_helper_indices.difference(all_path_indices), reverse=True)215 `,216 javascript: `TODO`,217 typescript: `TODO`,218 },219 get_item_position: {220 python: `221 def get_item_position(typ: SSZType, index_or_variable_name: Union[int, SSZVariableName]) -> Tuple[int, int, int]:222 """223 Return three variables:224 (i) the index of the chunk in which the given element of the item is represented;225 (ii) the starting byte position within the chunk;226 (iii) the ending byte position within the chunk.227 For example: for a 6-item list of uint64 values, index=2 will return (0, 16, 24), index=5 will return (1, 8, 16)228 """229 if issubclass(typ, Elements):230 index = int(index_or_variable_name)231 start = index * item_length(typ.elem_type)232 return start // 32, start % 32, start % 32 + item_length(typ.elem_type)233 elif issubclass(typ, Container):234 variable_name = index_or_variable_name235 return typ.get_field_names().index(variable_name), 0, item_length(get_elem_type(typ, variable_name))236 else:237 raise Exception("Only lists/vectors/containers supported")238 `,239 javascript: `TODO`,240 typescript: `TODO`,241 },242 get_path_indices: {243 python: `244 def get_path_indices(tree_index: GeneralizedIndex) -> Sequence[GeneralizedIndex]:245 """246 Get the generalized indices of the chunks along the path from the chunk with the247 given tree index to the root.248 """249 o = [tree_index]250 while o[-1] > 1:251 o.append(generalized_index_parent(o[-1]))252 return o[:-1]253 `,254 javascript: `TODO`,255 typescript: `TODO`,256 item_length: {257 python: `258 def item_length(typ: SSZType) -> int:259 """260 Return the number of bytes in a basic type, or 32 (a full hash) for compound types.261 """262 if issubclass(typ, BasicValue):263 return typ.byte_len264 else:265 return 32266 `,267 javascript: `TODO`,268 typescript: `TODO`,269 },270 merkle_tree: {271 python: `272 def merkle_tree(leaves: Sequence[Bytes32]) -> Sequence[Bytes32]:273 """274 Return an array representing the tree nodes by generalized index:275 [0, 1, 2, 3, 4, 5, 6, 7], where each layer is a power of 2. The 0 index is ignored. The 1 index is the root.276 The result will be twice the size as the padded bottom layer for the input leaves.277 """278 bottom_length = get_power_of_two_ceil(len(leaves))279 o = [Bytes32()] * bottom_length + list(leaves) + [Bytes32()] * (bottom_length - len(leaves))280 for i in range(bottom_length - 1, 0, -1):281 o[i] = hash(o[i * 2] + o[i * 2 + 1])282 return o283 `,284 javascript: `TODO`,285 typescript: `TODO`,286 },287 verify_merkle_multiproof: {288 python: `289 def calculate_multi_merkle_root(leaves: Sequence[Bytes32], proof: Sequence[Bytes32], indices: Sequence[GeneralizedIndex]) -> Root:290 assert len(leaves) == len(indices)291 helper_indices = get_helper_indices(indices)292 assert len(proof) == len(helper_indices)293 objects = {294 **{index: node for index, node in zip(indices, leaves)},295 **{index: node for index, node in zip(helper_indices, proof)}296 }297 keys = sorted(objects.keys(), reverse=True)298 pos = 0299 while pos < len(keys):300 k = keys[pos]301 if k in objects and k ^ 1 in objects and k // 2 not in objects:302 objects[GeneralizedIndex(k // 2)] = hash(303 objects[GeneralizedIndex((k | 1) ^ 1)] +304 objects[GeneralizedIndex(k | 1)]305 )306 keys.append(GeneralizedIndex(k // 2))307 pos += 1308 return objects[GeneralizedIndex(1)]309 `,310 javascript: `TODO`,311 typescript: `TODO`,312 },313 verify_merkle_proof: {314 python: `315 def verify_merkle_proof(leaf: Bytes32, proof: Sequence[Bytes32], index: GeneralizedIndex, root: Root) -> bool:316 return calculate_merkle_root(leaf, proof, index) == root317 `,318 javascript: `TODO`,319 typescript: `TODO`,320 },321 },322};323export default function AllFunctions(props) {324 return;...

Full Screen

Full Screen

extend.js

Source:extend.js Github

copy

Full Screen

1/* */ 2"use strict";3/*global chai, describe, it, window*/4// Tests for extend5describe("extend", function() {6 var expect, extend;7 8 // node9 if (typeof chai === "undefined") {10 extend = require("../index.js");11 expect = require("./lib/chai").expect;12 }13 // browser14 else {15 extend = window.extend;16 expect = chai.expect;17 }18 19 20 // Class A (root)21 function A(name, value) {22 this.id = A.nextId++;23 if (name) {24 this.name = name;25 }26 if (value) {27 this.value = value;28 }29 }30 31 A.nextId = 1;32 33 A.className = A.prototype.className = "A";34 35 A.prototype.name = "unknown";36 37 A.prototype.value = null;38 39 A.prototype.getInheritanceChain = function() {40 return A.className;41 };42 43 A.prototype.getTime = function() {44 return new Date().getTime();45 };46 47 A.prototype.toString = function() {48 return [49 this.className, 50 "[",51 this.id, 52 ", ",53 this.name,54 "]; inheritance: ",55 this.getInheritanceChain()56 ].join("");57 };58 59 // Class B (extends A)60 function B() {61 B.superconstructor.apply(this, arguments);62 }63 extend(B, A);64 65 B.className = B.prototype.className = "B";66 67 B.prototype.value = "none";68 69 B.prototype.getInheritanceChain = function() {70 return B.superclass.getInheritanceChain.call(this) + " <- " + B.className;71 };72 73 // Class C (extends A)74 function C() {75 C.superconstructor.apply(this, arguments);76 }77 extend(C, A);78 79 C.className = C.prototype.className = "C";80 81 C.prototype.value = "no";82 83 C.prototype.methodC = function() {84 return this;85 };86 87 C.prototype.getInheritanceChain = function() {88 return C.superclass.getInheritanceChain.call(this) + " <- " + C.className;89 };90 91 // Class SubC (extends C)92 function SubC() {93 SubC.superconstructor.apply(this, arguments);94 }95 extend(SubC, C);96 97 SubC.className = SubC.prototype.className = "SubC";98 99 SubC.prototype.getInheritanceChain = function() {100 return SubC.superclass.getInheritanceChain.call(this) + " <- " + SubC.className;101 };102 103 104 // Tests105 106 describe("simple inheritance", function() {107 var objB = new B("b"),108 objC = new C("c", "c value"),109 objSubC = new SubC();110 111 it("instanceof should work", function() {112 expect(objB instanceof B)113 .equal(true);114 expect(objB instanceof A)115 .equal(true);116 117 expect(objC instanceof C)118 .equal(true);119 expect(objC instanceof A)120 .equal(true);121 122 expect(objSubC instanceof SubC)123 .equal(true);124 expect(objSubC instanceof C)125 .equal(true);126 expect(objSubC instanceof A)127 .equal(true);128 });129 130 it("object should have properties that are defined in superclass", function() {131 expect(objB)132 .have.ownProperty("id")133 .have.ownProperty("name")134 .respondTo("getInheritanceChain")135 .respondTo("getTime")136 .have.property("value", "none")137 .not // Negates any of assertions following in the chain138 .have.ownProperty("value")139 .have.ownProperty("getInheritanceChain")140 .have.ownProperty("getTime");141 expect(objB.id)142 .a("number")143 .above(0);144 expect(objB.name)145 .a("string")146 .equal("b");147 expect(objB.toString())148 .equal("B[" + objB.id + ", b]; inheritance: A <- B");149 150 expect(objC)151 .have.ownProperty("id")152 .have.ownProperty("name")153 .have.ownProperty("value")154 .respondTo("getInheritanceChain")155 .respondTo("getTime")156 .not // Negates any of assertions following in the chain157 .have.ownProperty("getInheritanceChain")158 .have.ownProperty("getTime");159 expect(objC.id)160 .a("number")161 .above(0);162 expect(objC.name)163 .a("string")164 .equal("c");165 expect(objC.value)166 .a("string")167 .equal("c value");168 expect(objC.toString())169 .equal("C[" + objC.id + ", c]; inheritance: A <- C");170 171 expect(objSubC)172 .have.ownProperty("id")173 .respondTo("getInheritanceChain")174 .respondTo("getTime")175 .respondTo("methodC")176 .have.property("value", "no")177 .not // Negates any of assertions following in the chain178 .have.ownProperty("name")179 .have.ownProperty("value")180 .have.ownProperty("getInheritanceChain")181 .have.ownProperty("getTime")182 .have.ownProperty("methodC");183 expect(objSubC.id)184 .a("number")185 .above(0);186 expect(objSubC.name)187 .a("string")188 .equal("unknown");189 expect(objSubC.toString())190 .equal("SubC[" + objSubC.id + ", unknown]; inheritance: A <- C <- SubC");191 });192 });193 194 describe(".isSubclass", function() {195 function D() {196 }197 extend(D, B);198 199 var isSubclass = extend.isSubclass;200 201 it("should be subclass", function() {202 expect( isSubclass(B, A) )203 .equal(true);204 expect( isSubclass(C, A) )205 .equal(true);206 expect( isSubclass(D, A) )207 .equal(true);208 expect( isSubclass(D, B) )209 .equal(true);210 });211 it("should not be subclass", function() {212 expect( isSubclass(A, B) )213 .equal(false);214 expect( isSubclass(A, C) )215 .equal(false);216 expect( isSubclass(B, C) )217 .equal(false);218 expect( isSubclass(C, B) )219 .equal(false);220 expect( isSubclass(B, D) )221 .equal(false);222 expect( isSubclass(C, D) )223 .equal(false);224 expect( isSubclass(D, C) )225 .equal(false);226 });227 });...

Full Screen

Full Screen

fo3test.js

Source:fo3test.js Github

copy

Full Screen

...147});148var e = Employee.create({name: 'Jane', age: 30, salary: 50000});149console.log(e.toString());150e.sayGoodbye();151console.assert(Person.isSubClass(Employee), 'isSubClass false negative.');152console.assert(!Employee.isSubClass(Person), 'isSubClass false positive.');153console.assert(! Person.isSubClass(ConstantTest), 'isSubClass false positive.');154console.assert(Person.isInstance(p), 'isInstance false negative.');155console.assert(!Employee.isInstance(p), 'isInstance false positive.');156console.assert(Person.isInstance(e), 'isInstance false negative.');157console.assert(! Person.isInstance(t1), 'isInstance false positive.');158console.assert(Person.getAxiomByName('age') === Person.AGE, 'Class.getAxiomByName() doesn\'t work.');159var axs = Person.getAxiomsByClass(Property);160console.assert(axs.length == 2 && axs[0] === Person.NAME && axs[1] === Person.AGE, 'Class.getAxiomsByClass() doesn\'t work.');161console.assert(Person.getAxioms().length === 6, 'Missing axiom from getAxioms().');162/*163// 3058ms, Jan 26, 2016, X1 Carbon164// 2727ms, Feb 1, " "165console.time('b1');166for ( var i = 0 ; i < 10000000 ; i++ )167 p.age++;...

Full Screen

Full Screen

Session.js

Source:Session.js Github

copy

Full Screen

1import { ORM } from "../..";2import { createTestModels, isSubclass } from "../helpers";3import { CREATE } from "../../constants";4describe("Session", () => {5 let orm;6 let Book;7 let Cover;8 let Genre;9 let Tag;10 let Author;11 let Publisher;12 let emptyState;13 beforeEach(() => {14 ({ Book, Cover, Genre, Tag, Author, Publisher } = createTestModels());15 orm = new ORM();16 orm.register(Book, Cover, Genre, Tag, Author, Publisher);17 emptyState = orm.getEmptyState();18 });19 it("connects models", () => {20 expect(Book.session).toBeUndefined();21 expect(Cover.session).toBeUndefined();22 expect(Genre.session).toBeUndefined();23 expect(Tag.session).toBeUndefined();24 expect(Cover.session).toBeUndefined();25 expect(Publisher.session).toBeUndefined();26 const session = orm.session();27 expect(session.Book.session).toBe(session);28 expect(session.Cover.session).toBe(session);29 expect(session.Genre.session).toBe(session);30 expect(session.Tag.session).toBe(session);31 expect(session.Cover.session).toBe(session);32 expect(session.Publisher.session).toBe(session);33 });34 it("exposes models as getter properties", () => {35 const session = orm.session();36 expect(isSubclass(session.Book, Book)).toBe(true);37 expect(isSubclass(session.Author, Author)).toBe(true);38 expect(isSubclass(session.Cover, Cover)).toBe(true);39 expect(isSubclass(session.Genre, Genre)).toBe(true);40 expect(isSubclass(session.Tag, Tag)).toBe(true);41 expect(isSubclass(session.Publisher, Publisher)).toBe(true);42 });43 it("marks models when full table scan has been performed", () => {44 const session = orm.session();45 expect(session.fullTableScannedModels).toHaveLength(0);46 session.markFullTableScanned(Book.modelName);47 expect(session.fullTableScannedModels).toHaveLength(1);48 expect(session.fullTableScannedModels[0]).toBe("Book");49 session.markFullTableScanned(Book.modelName);50 expect(session.fullTableScannedModels[0]).toBe("Book");51 });52 it("marks accessed model instances", () => {53 const session = orm.session();54 expect(session.accessedModelInstances).toEqual({});55 session.markAccessed(Book.modelName, [0]);56 expect(session.accessedModelInstances).toEqual({57 Book: {58 0: true,59 },60 });61 session.markAccessed(Book.modelName, [1]);62 expect(session.accessedModelInstances).toEqual({63 Book: {64 0: true,65 1: true,66 },67 });68 });69 it("throws when failing to apply updates", () => {70 const session = orm.session();71 session.db = {72 update() {73 return {74 payload: 123,75 status: "failed",76 state: {},77 };78 },79 };80 expect(() => session.applyUpdate({})).toThrow(81 "Applying update failed with status failed. Payload: 123"82 );83 });84 describe("gets the next state", () => {85 it("without any updates, the same state is returned", () => {86 const session = orm.session();87 expect(session.state).toEqual(emptyState);88 });89 it("with updates, a new state is returned", () => {90 const session = orm.session(emptyState);91 session.applyUpdate({92 table: Author.modelName,93 action: CREATE,94 payload: {95 id: 0,96 name: "Caesar",97 },98 });99 const nextState = session.state;100 expect(nextState).not.toBe(emptyState);101 expect(nextState[Author.modelName]).not.toBe(102 emptyState[Author.modelName]103 );104 // All other model states should stay equal.105 expect(nextState[Book.modelName]).toBe(emptyState[Book.modelName]);106 expect(nextState[Cover.modelName]).toBe(107 emptyState[Cover.modelName]108 );109 expect(nextState[Genre.modelName]).toBe(110 emptyState[Genre.modelName]111 );112 expect(nextState[Tag.modelName]).toBe(emptyState[Tag.modelName]);113 expect(nextState[Publisher.modelName]).toBe(114 emptyState[Publisher.modelName]115 );116 });117 });...

Full Screen

Full Screen

creating_types.js

Source:creating_types.js Github

copy

Full Screen

1module('creating things');2test('class is created with correct attributes', function() {3 var type=py.type,4 object=py.object;5 var target=type('Name', [object], {});6 equal(target.__class__, type);7 equal(target.__base__, object);8 deepEqual(target.__bases__, [object]);9 deepEqual(target.__mro__, [target, object]);10 ok(py.isinstance(target, type));11 ok(py.issubclass(target, object));12});13test('instance is created with correct attributes', function() {14 var type=py.type,15 object=py.object;16 var cls=type('Name', [object], {});17 var instance=cls();18 equal(instance.__class__, cls);19 ok(py.isinstance(instance, cls));20 ok(py.issubclass(instance, object));21});22test('subclass created with correct attributes', function() {23 var type=py.type,24 object=py.object;25 var name=type('Name', [object], {}),26 target=type('Subclass', [name], {});27 equal(target.__class__, type, '__class__');28 equal(target.__base__, name, '__base__');29 deepEqual(target.__bases__, [name, object], '__bases__');30 deepEqual(target.__mro__, [target, name, object], '__mro__');31 ok(py.isinstance(target, type), 'isinstance(target, type)');32 ok(py.issubclass(target, name), 'issubclass(target, name)');33 ok(py.issubclass(target, object), 'issubclass(target, object)');34});35test('various classes mro (1)', function() {36 var type=py.type,37 object=py.object,38 O = object,39 F = type('F', [O], {}),40 E = type('E', [O], {}),41 D = type('D', [O], {}),42 C = type('C', [D, F], {}),43 B = type('B', [D, E], {}),44 A = type('A', [B, C], {});45 deepEqual(F.__mro__, [F,O]);46 deepEqual(E.__mro__, [E,O]);47 deepEqual(D.__mro__, [D,O]);48 deepEqual(C.__mro__, [C,D,F,O] );49 deepEqual(B.__mro__, [B,D,E,O]);50 deepEqual(A.__mro__, [A,B,C,D,E,F,O]);51});52test('various classes mro (2)', function() {53 var type=py.type,54 object=py.object,55 O = object,56 F = type('F', [O], {}),57 E = type('E', [O], {}),58 D = type('D', [O], {}),59 C = type('C', [D, F], {}),60 B = type('B', [E, D], {}),61 A = type('A', [B, C], {});62 deepEqual(F.__mro__, [F,O]);63 deepEqual(E.__mro__, [E,O]);64 deepEqual(D.__mro__, [D,O]);65 deepEqual(C.__mro__, [C,D,F,O]);66 deepEqual(B.__mro__, [B,E,D,O]);67 deepEqual(A.__mro__, [A,B,E,C,D,F,O]);...

Full Screen

Full Screen

issubclass.js

Source:issubclass.js Github

copy

Full Screen

1var exceptions = require('../core').exceptions2var types = require('../types')3function issubclass(args, kwargs) {4 if (arguments.length !== 2) {5 throw new exceptions.BataviaError.$pyclass('Batavia calling convention not used.')6 }7 if (kwargs && Object.keys(kwargs).length > 0) {8 throw new exceptions.TypeError.$pyclass('issubclass() takes no keyword arguments')9 }10 if (!args || args.length !== 2) {11 throw new exceptions.TypeError.$pyclass('issubclass expected 2 arguments, got ' + args.length)12 }13 if (!types.isinstance(args[0], types.Type)) {14 throw new exceptions.TypeError.$pyclass('issubclass() arg 1 must be a class')15 }16 if (types.isinstance(args[1], types.Type)) {17 return new types.Bool(types.issubclass(args[0], args[1]))18 }19 if (types.isinstance(args[1], types.Tuple)) {20 if (args[1].every((element) => types.isinstance(element, types.Type))) {21 return new types.Bool(types.issubclass(args[0], [...args[1]]))22 }23 }24 throw new exceptions.TypeError.$pyclass('issubclass() arg 2 must be a class or tuple of classes')25}26issubclass.__doc__ = 'issubclass(C, B) -> bool\n\nReturn whether class C is a subclass (i.e., a derived class) of class B.\nWhen using a tuple as the second argument issubclass(X, (A, B, ...)),\nis a shortcut for issubclass(X, A) or issubclass(X, B) or ... (etc.).'...

Full Screen

Full Screen

release.js

Source:release.js Github

copy

Full Screen

1const app = getApp();2import storages from '../../utils/storages.js'3var util = require('../../utils/util.js')4Page({5 data: {6 StatusBar: app.globalData.StatusBar,7 CustomBar: app.globalData.CustomBar, 8 Category: []9 },10 showModal(e) {11 let classid = e.currentTarget.dataset.id12 let index = e.currentTarget.dataset.index13 let isSubClass = this.data.Category[index].subclass;14 if(isSubClass==undefined){15 util.ToPage('releaseform?classid=' + classid + '&subclassid=')16 }else{17 //子类的Name18 var itemListText = [];19 for (var i in isSubClass) {20 itemListText.push(isSubClass[i]['name']);21 }22 wx.showActionSheet({23 itemList: itemListText,24 success:function(res){25 //子类id26 let secondClassID = itemListText[res.tapIndex].typeid27 util.ToPage('releaseform?classid=' + classid + '&subclassid=' + secondClassID)28 }29 })30 }31 32 },33 onLoad(e){ 34 var that = this35 //栏目36 if(storages.get('cache_category')){ 37 that.setData({38 Category: storages.get('cache_category')39 })40 }else{41 util.http(app.globalData.BaseUrl+'types', function (data) {42 that.setData({43 Category: data44 })45 storages.put('cache_category',data)46 })47 }48 49 }...

Full Screen

Full Screen

classes_test.mjs

Source:classes_test.mjs Github

copy

Full Screen

1import Classes from '/zuzia/v0.2/__packages__/base/classes.mjs';2const {describe, it} = window.Mocha;3const chai = window.chai;4describe('Classes', function () {5 class Base {6 f() { return 'Base'; }7 };8 class Derived extends Base {9 f() { return super.f() + 'Derived'; }10 };11 it('isSubclass', function () {12 chai.assert(Classes.isSubclass(Derived, Base));13 chai.assert(!Classes.isSubclass(Base, Derived));14 chai.assert(!Classes.isSubclass(Base, Base));15 chai.assert(!Classes.isSubclass(Derived, Derived));16 });17 it('getBaseClass', function () {18 assertIs(Classes.getBaseClass(Derived), Base);19 chai.assert.isNull(Classes.getBaseClass(Base));20 });21 it('withBaseClass', function () {22 const Derived2 = Classes.withBaseClass(class Derived2 {23 f() { return super.f() + 'Derived2'; }24 }, Base);25 assertIs(Classes.getBaseClass(Derived2), Base);26 chai.assert.equal(Derived2.name, 'Derived2');27 chai.assert.isNull(Classes.getBaseClass(Base));28 chai.assert.equal((new Derived2).f(), 'BaseDerived2');29 chai.assert.equal((new Base).f(), 'Base');30 // TODO: test throws31 // Classes.withBaseClass(Derived, Base);32 });33 function assertIs(a, b) {34 chai.assert(Object.is(a, b));35 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wd = require('wd');2var asserters = wd.asserters;3var serverConfigs = {4};5var desiredCaps = {6};7var driver = wd.promiseChainRemote(serverConfigs);8 .init(desiredCaps)9 .then(function () {10 return driver.sleep(10000);11 })12 .then(function () {13 return driver.isSubClass('android.widget.Button', 'android.view.View');14 })15 .then(function (isSubclass) {16 console.log('isSubclass: ' + isSubclass);17 })18 .then(function () {19 return driver.quit();20 })21 .done();

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Appium automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful