How to use func2 method in wpt

Best JavaScript code snippet using wpt

index.js

Source:index.js Github

copy

Full Screen

...7 Base.prototype = {8 func1: function func1() {9 return 'this is func1';10 },11 func2: function func2() {12 return 'this is func2';13 },14 func3: function func3() {15 return 'this is func3';16 }17 };18 Base.staticProp = 'BaseStaticProp';19 describe('suns existence', function () {20 it('is an object', function () {21 suns.should.be.a('object');22 });23 it('version', function () {24 suns.VERSION.should.be.ok;25 });26 });27 describe('normal extending', function () {28 var Child = suns.extend(Base, {29 childfunc1: function childfunc1() {30 return 'this is childfunc1';31 },32 /**33 * @override34 */35 func2: function func2() {36 return 'this is overriden func2';37 }38 });39 var c = new Child();40 it('should have parent property', function () {41 c.should.have.property('func1');42 c.func1().should.be.equal('this is func1');43 });44 it('should have child property', function () {45 c.should.have.property('childfunc1');46 c.childfunc1().should.be.equal('this is childfunc1');47 });48 it('should override parents function', function () {49 c.should.have.property('func2');50 c.func2().should.be.equal('this is overriden func2');51 });52 it('should be able to call parents function', function () {53 c.should.have.property('func2');54 Child.__super__.func2.call(c).should.be.equal('this is func2');55 });56 });57 describe('normal extending with function name', function () {58 var Child = suns.extend(59 'Child',60 Base, {61 childfunc1: function childfunc1() {62 return 'this is childfunc1';63 },64 /**65 * @override66 */67 func2: function func2() {68 return 'this is overriden func2';69 }70 });71 var c = new Child();72 it('should have parent property', function () {73 c.should.have.property('func1');74 c.func1().should.be.equal('this is func1');75 });76 it('should have child property', function () {77 c.should.have.property('childfunc1');78 c.childfunc1().should.be.equal('this is childfunc1');79 });80 it('should override parents function', function () {81 c.should.have.property('func2');82 c.func2().should.be.equal('this is overriden func2');83 });84 it('should be able to call parents function', function () {85 c.should.have.property('func2');86 Child.__super__.func2.call(c).should.be.equal('this is func2');87 });88 });89 describe('multiple extending', function () {90 var Child = suns.extend(91 Base,92 {93 childfunc1: function childfunc1() {94 return 'this is childfunc1';95 },96 /**97 * @override98 */99 func2: function func2() {100 return 'this is overriden func2';101 }102 },103 {104 childchildfunc1: function childchildfunc1() {105 return 'this is childchildfunc1';106 },107 /**108 * @override109 */110 func2: function func2() {111 return 'this is overoverriden func2';112 },113 /**114 * @override115 */116 func3: function func3() {117 return 'this is overriden func3';118 }119 }120 );121 var c = new Child();122 it('should have parent property', function () {123 c.should.have.property('func1');124 c.func1().should.be.equal('this is func1');125 });126 it('should have child property', function () {127 c.should.have.property('childfunc1');128 c.should.have.property('childchildfunc1');129 c.childfunc1().should.be.equal('this is childfunc1');130 c.childchildfunc1().should.be.equal('this is childchildfunc1');131 });132 it('should override parents function', function () {133 c.should.have.property('func2');134 c.func2().should.be.equal('this is overoverriden func2');135 });136 it('should be able to call parents function', function () {137 Child.__super__.should.have.property('func2');138 Child.__super__.func2.call(c).should.be.equal('this is overriden func2');139 });140 it('should be able to call parents function', function () {141 Child.__super__.should.have.property('func2');142 Child.__supersuper__.func2.call(c).should.be.equal('this is func2');143 });144 it('should have parents static property', function() {145 Child.should.have.property('staticProp');146 Child.staticProp.should.be.equal('BaseStaticProp');147 });148 });149 describe('multiple extending with name', function () {150 var Child = suns.extend(151 'Child',152 Base,153 {154 childfunc1: function childfunc1() {155 return 'this is childfunc1';156 },157 /**158 * @override159 */160 func2: function func2() {161 return 'this is overriden func2';162 }163 },164 {165 childchildfunc1: function childchildfunc1() {166 return 'this is childchildfunc1';167 },168 /**169 * @override170 */171 func2: function func2() {172 return 'this is overoverriden func2';173 },174 /**175 * @override176 */177 func3: function func3() {178 return 'this is overriden func3';179 }180 }181 );182 var c = new Child();183 it('should have parent property', function () {184 c.should.have.property('func1');185 c.func1().should.be.equal('this is func1');186 });187 it('should have child property', function () {188 c.should.have.property('childfunc1');189 c.should.have.property('childchildfunc1');190 c.childfunc1().should.be.equal('this is childfunc1');191 c.childchildfunc1().should.be.equal('this is childchildfunc1');192 });193 it('should override parents function', function () {194 c.should.have.property('func2');195 c.func2().should.be.equal('this is overoverriden func2');196 });197 it('should be able to call parents function', function () {198 Child.__super__.should.have.property('func2');199 Child.__super__.func2.call(c).should.be.equal('this is overriden func2');200 });201 it('should be able to call parents function', function () {202 Child.__super__.should.have.property('func2');203 Child.__supersuper__.func2.call(c).should.be.equal('this is func2');204 });205 });206 describe('constructor overriding', function() {207 var HasConstructor = suns.extend(208 'HasConstructor',209 Base,...

Full Screen

Full Screen

test_public.py

Source:test_public.py Github

copy

Full Screen

...47 check_func(func1, func1_case_3, True)48 check_func(func1, func1_case_4, True)49 check_func(func1, func1_case_5, True)50def func2_case_1() -> None:51 func2(None) # success52def func2_case_2() -> None:53 func2(True) # success54def func2_case_3() -> None:55 func2(1.0) # fail56def func2_case_4() -> None:57 func2("hello") # success58def func2_case_5() -> None:59 func2(["hello"]) # fail60def func2_case_6() -> None:61 func2({1, 2, 3}) # fail62def func2_case_7() -> None:63 func2([1, 2, 3]) # success64def func2_case_8() -> None:65 func2([1.0, 2.0, 3.0]) # fail66def func2_case_9() -> None:67 func2({1: "hello"}) # fail68def func2_case_10() -> None:69 T = tp.TypeVar("T", int, str)70 class A(tp.Sequence[T]):71 def __init__(self, value: T):72 self._a: T = value73 @tp.overload # noqa: F81174 def __getitem__(self, i: int) -> T: # noqa: F81175 pass76 @tp.overload # noqa: F81177 def __getitem__(self, s: slice) -> tp.Sequence[T]: # noqa: F81178 pass79 def __getitem__(self, i): # noqa: F81180 return self._a81 def __len__(self) -> int:82 pass83 func2(A[str]("hello")) # fail84def func2_case_11() -> None:85 T = tp.TypeVar("T", bool, str)86 class A(tp.Sequence[T]):87 def __init__(self, value: T):88 self._a: T = value89 @tp.overload # noqa: F81190 def __getitem__(self, i: int) -> T: # noqa: F81191 pass92 @tp.overload # noqa: F81193 def __getitem__(self, s: slice) -> tp.Sequence[T]: # noqa: F81194 pass95 def __getitem__(self, i): # noqa: F81196 return self._a97 def __len__(self) -> int:98 pass99 func2(A[bool](True)) # success100def test_func2() -> None:101 check_annotations(func2)102 check_func(func2, func2_case_1, True)103 check_func(func2, func2_case_2, True)104 check_func(func2, func2_case_3, False)105 check_func(func2, func2_case_4, True)106 check_func(func2, func2_case_5, False)107 check_func(func2, func2_case_6, False)108 check_func(func2, func2_case_7, True)109 check_func(func2, func2_case_8, False)110 check_func(func2, func2_case_9, False)111 check_func(func2, func2_case_10, False)112 check_func(func2, func2_case_11, True)113def func3_case_1() -> None:114 func3((1, "re", "rt", ["a", "b", "c"])) # success...

Full Screen

Full Screen

test_multiple_pipelines.py

Source:test_multiple_pipelines.py Github

copy

Full Screen

1from stairs.tests.flows.name_extraction import (NameExtractionOneWayFlow,2 NameExtractionFlowMultiple)3from stairs.core.pipeline.data_pipeline import concatenate4from utils import run_pipelines, GlobalTestData5def test_connected_pipelines(app):6 @app.pipeline()7 def p_builder(worker, sentence, use_lower):8 data = concatenate(sentence=sentence,9 use_lower=use_lower)10 data_with_name = data \11 .subscribe_flow(NameExtractionOneWayFlow(),12 as_worker=False)13 return data_with_name14 @app.pipeline()15 def p_builder_general(worker, sentence, use_lower):16 data = concatenate(sentence=sentence,17 use_lower=use_lower)18 return data.subscribe_pipeline(p_builder)\19 .subscribe_flow(NameExtractionFlowMultiple(),20 as_worker=False)21 p_builder.compile()22 p_builder_general.compile()23 p_builder_general(sentence="Oleg", use_lower=True)24 run_pipelines(app)25def test_connected_pipelines_multiple(app):26 t = GlobalTestData()27 @app.pipeline()28 def p_builder(worker, sentence, use_lower):29 data = concatenate(sentence=sentence,30 use_lower=use_lower)31 data_with_name = data\32 .subscribe_flow(NameExtractionOneWayFlow())33 return data_with_name34 @app.pipeline()35 def p_builder_general(worker, sentence, use_lower):36 data = concatenate(sentence=sentence,37 use_lower=use_lower)38 v1 = data.subscribe_pipeline(p_builder)\39 .subscribe_flow(NameExtractionFlowMultiple(use_lower=use_lower))40 v2 = data.subscribe_pipeline(p_builder)\41 .subscribe_flow(NameExtractionFlowMultiple(use_lower=use_lower))42 return concatenate(v1=v1, v2=v2).subscribe_func(t.save_one_item)43 p_builder.compile()44 p_builder_general.compile()45 p_builder_general(sentence="Oleg", use_lower=True)46 run_pipelines(app)47 result = t.get_result()48 assert result['v1']['names'][0] == "oleg"49 assert result['v2']['names'][0] == "oleg"50def test_deep_tree_functions(app):51 t = GlobalTestData()52 @app.consumer()53 def save_globaly(name, result , **kwargs):54 t.save_multiple_items(**{name: result})55 @app.pipeline()56 def p_builder(worker, sentence):57 root_branch = sentence \58 .subscribe_func(lambda sentence: dict(func1="ok"), name='root1') \59 .subscribe_func(lambda sentence: dict(func2="ok"), name='root2')60 return concatenate(61 branch_1=root_branch.subscribe_pipeline(branch_1),62 branch_2=root_branch.subscribe_pipeline(branch_2),63 branch_3=root_branch.subscribe_pipeline(branch_3)64 )65 @app.pipeline()66 def branch_1(work, func1, func2):67 root_branch = concatenate(func1=func1, func2=func2)68 return root_branch \69 .add_value(name='branch_1') \70 .subscribe_func(lambda func1, func2: dict(func1_1="ok"),71 name='branch_1_1') \72 .subscribe_func(lambda func1, func2: dict(result="branch_1"),73 name='branch_1_2')\74 .subscribe_consumer(save_globaly)75 @app.pipeline()76 def branch_2(work, func1, func2):77 root_branch = concatenate(func1=func1, func2=func2)78 return root_branch \79 .add_value(name='branch_2') \80 .subscribe_func(lambda func1, func2: dict(func1_1="ok"),81 name='branch_2_1') \82 .subscribe_func(lambda func1, func2: dict(result="branch_2"),83 name='branch_2_2')\84 .subscribe_consumer(save_globaly)85 @app.pipeline()86 def branch_3(work, func1, func2):87 root_branch = concatenate(func1=func1, func2=func2)88 return root_branch \89 .add_value(name='branch_3') \90 .subscribe_func(lambda func1, func2: dict(func1_1="ok"),91 name='branch_3_1') \92 .subscribe_func(lambda func1, func2: dict(result="branch_3"),93 name='branch_3_2')\94 .subscribe_consumer(save_globaly)95 p_builder.compile()96 branch_1.compile()97 branch_2.compile()98 branch_3.compile()99 p_builder(sentence="Oleg", use_lower=True)100 run_pipelines(app)101 result = t.get_result()102 assert len(result) == 3103 assert list(result[0].keys()) == list(result[0].values())104 assert list(result[1].keys()) == list(result[1].values())105 assert list(result[2].keys()) == list(result[2].values())106def test_deep_tree_functions_of_producers(app):107 t = GlobalTestData()108 @app.consumer()109 def save_globaly(name, result , **kwargs):110 t.save_multiple_items(**{name: result})111 @app.pipeline()112 def p_builder(worker, sentence):113 root_branch = sentence \114 .subscribe_func_as_producer(lambda sentence: [dict(func1="ok"),115 dict(func1="ok"), ],116 name='root1') \117 .subscribe_func_as_producer(lambda sentence: [dict(func2="ok"),118 dict(func2="ok"), ],119 name='root2')120 return concatenate(121 branch_1=root_branch.subscribe_pipeline(branch_1),122 branch_2=root_branch.subscribe_pipeline(branch_2),123 branch_3=root_branch.subscribe_pipeline(branch_3)124 )125 @app.pipeline()126 def branch_1(work, func1, func2):127 root_branch = concatenate(func1=func1, func2=func2)128 return root_branch \129 .add_value(name='branch_1') \130 .subscribe_func(lambda func1, func2: dict(func1_1="ok"),131 name='branch_1_1') \132 .subscribe_func(lambda func1, func2: dict(result="branch_1"),133 name='branch_1_2')\134 .subscribe_consumer(save_globaly)135 @app.pipeline()136 def branch_2(work, func1, func2):137 root_branch = concatenate(func1=func1, func2=func2)138 return root_branch \139 .add_value(name='branch_2') \140 .subscribe_func(lambda func1, func2: dict(func1_1="ok"),141 name='branch_2_1') \142 .subscribe_func(lambda func1, func2: dict(result="branch_2"),143 name='branch_2_2')\144 .subscribe_consumer(save_globaly)145 @app.pipeline()146 def branch_3(work, func1, func2):147 root_branch = concatenate(func1=func1, func2=func2)148 return root_branch \149 .add_value(name='branch_3') \150 .subscribe_func(lambda func1, func2: dict(func1_1="ok"),151 name='branch_3_1') \152 .subscribe_func(lambda func1, func2: dict(result="branch_3"),153 name='branch_3_2')\154 .subscribe_consumer(save_globaly)155 p_builder.compile()156 branch_1.compile()157 branch_2.compile()158 branch_3.compile()159 p_builder(sentence="Oleg", use_lower=True)160 run_pipelines(app)161 result = t.get_result()...

Full Screen

Full Screen

scopes_test.py

Source:scopes_test.py Github

copy

Full Screen

...21@scopes.add_arg_scope22def func1(*args, **kwargs):23 return (args, kwargs)24@scopes.add_arg_scope25def func2(*args, **kwargs):26 return (args, kwargs)27class ArgScopeTest(tf.test.TestCase):28 def testEmptyArgScope(self):29 with self.test_session():30 self.assertEqual(scopes._current_arg_scope(), {})31 def testCurrentArgScope(self):32 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}33 key_op = (func1.__module__, func1.__name__)34 current_scope = {key_op: func1_kwargs.copy()}35 with self.test_session():36 with scopes.arg_scope([func1], a=1, b=None, c=[1]) as scope:37 self.assertDictEqual(scope, current_scope)38 def testCurrentArgScopeNested(self):39 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}40 func2_kwargs = {'b': 2, 'd': [2]}41 key = lambda f: (f.__module__, f.__name__)42 current_scope = {key(func1): func1_kwargs.copy(),43 key(func2): func2_kwargs.copy()}44 with self.test_session():45 with scopes.arg_scope([func1], a=1, b=None, c=[1]):46 with scopes.arg_scope([func2], b=2, d=[2]) as scope:47 self.assertDictEqual(scope, current_scope)48 def testReuseArgScope(self):49 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}50 key_op = (func1.__module__, func1.__name__)51 current_scope = {key_op: func1_kwargs.copy()}52 with self.test_session():53 with scopes.arg_scope([func1], a=1, b=None, c=[1]) as scope1:54 pass55 with scopes.arg_scope(scope1) as scope:56 self.assertDictEqual(scope, current_scope)57 def testReuseArgScopeNested(self):58 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}59 func2_kwargs = {'b': 2, 'd': [2]}60 key = lambda f: (f.__module__, f.__name__)61 current_scope1 = {key(func1): func1_kwargs.copy()}62 current_scope2 = {key(func1): func1_kwargs.copy(),63 key(func2): func2_kwargs.copy()}64 with self.test_session():65 with scopes.arg_scope([func1], a=1, b=None, c=[1]) as scope1:66 with scopes.arg_scope([func2], b=2, d=[2]) as scope2:67 pass68 with scopes.arg_scope(scope1):69 self.assertDictEqual(scopes._current_arg_scope(), current_scope1)70 with scopes.arg_scope(scope2):71 self.assertDictEqual(scopes._current_arg_scope(), current_scope2)72 def testSimpleArgScope(self):73 func1_args = (0,)74 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}75 with self.test_session():76 with scopes.arg_scope([func1], a=1, b=None, c=[1]):77 args, kwargs = func1(0)78 self.assertTupleEqual(args, func1_args)79 self.assertDictEqual(kwargs, func1_kwargs)80 def testSimpleArgScopeWithTuple(self):81 func1_args = (0,)82 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}83 with self.test_session():84 with scopes.arg_scope((func1,), a=1, b=None, c=[1]):85 args, kwargs = func1(0)86 self.assertTupleEqual(args, func1_args)87 self.assertDictEqual(kwargs, func1_kwargs)88 def testOverwriteArgScope(self):89 func1_args = (0,)90 func1_kwargs = {'a': 1, 'b': 2, 'c': [1]}91 with scopes.arg_scope([func1], a=1, b=None, c=[1]):92 args, kwargs = func1(0, b=2)93 self.assertTupleEqual(args, func1_args)94 self.assertDictEqual(kwargs, func1_kwargs)95 def testNestedArgScope(self):96 func1_args = (0,)97 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}98 with scopes.arg_scope([func1], a=1, b=None, c=[1]):99 args, kwargs = func1(0)100 self.assertTupleEqual(args, func1_args)101 self.assertDictEqual(kwargs, func1_kwargs)102 func1_kwargs['b'] = 2103 with scopes.arg_scope([func1], b=2):104 args, kwargs = func1(0)105 self.assertTupleEqual(args, func1_args)106 self.assertDictEqual(kwargs, func1_kwargs)107 def testSharedArgScope(self):108 func1_args = (0,)109 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}110 with scopes.arg_scope([func1, func2], a=1, b=None, c=[1]):111 args, kwargs = func1(0)112 self.assertTupleEqual(args, func1_args)113 self.assertDictEqual(kwargs, func1_kwargs)114 args, kwargs = func2(0)115 self.assertTupleEqual(args, func1_args)116 self.assertDictEqual(kwargs, func1_kwargs)117 def testSharedArgScopeTuple(self):118 func1_args = (0,)119 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}120 with scopes.arg_scope((func1, func2), a=1, b=None, c=[1]):121 args, kwargs = func1(0)122 self.assertTupleEqual(args, func1_args)123 self.assertDictEqual(kwargs, func1_kwargs)124 args, kwargs = func2(0)125 self.assertTupleEqual(args, func1_args)126 self.assertDictEqual(kwargs, func1_kwargs)127 def testPartiallySharedArgScope(self):128 func1_args = (0,)129 func1_kwargs = {'a': 1, 'b': None, 'c': [1]}130 func2_args = (1,)131 func2_kwargs = {'a': 1, 'b': None, 'd': [2]}132 with scopes.arg_scope([func1, func2], a=1, b=None):133 with scopes.arg_scope([func1], c=[1]), scopes.arg_scope([func2], d=[2]):134 args, kwargs = func1(0)135 self.assertTupleEqual(args, func1_args)136 self.assertDictEqual(kwargs, func1_kwargs)137 args, kwargs = func2(1)138 self.assertTupleEqual(args, func2_args)139 self.assertDictEqual(kwargs, func2_kwargs)140if __name__ == '__main__':...

Full Screen

Full Screen

check.test.js

Source:check.test.js Github

copy

Full Screen

1import check from "./check";2import {strict as assert} from "assert";3function test(description, callback) {4 callback();5}6function call() {7 const func = function func(input) {8 func.called = true;9 func.input = input;10 };11 func.called = false;12 return func;13}14test("calls function for matched float", () => {15 const func1 = call();16 const func2 = call();17 check(1.3)18 .case(1.2, func1)19 .case(1.3, func2)20 .test();21 assert.ok(func2.called);22 assert.ok(!func1.called);23});24test("calls function for matched integer", () => {25 const func1 = call();26 const func2 = call();27 check(1)28 .case(1, func1)29 .case(2, func2)30 .test();31 assert.ok(func1.called);32 assert.ok(!func2.called);33});34test("calls function for matched string", () => {35 const func1 = call();36 const func2 = call();37 check("hello")38 .case("hi", func1)39 .case("hello", func2)40 .test();41 assert.ok(!func1.called);42 assert.ok(func2.called);43});44test("calls function for matched boolean (true)", () => {45 const func1 = call();46 const func2 = call();47 check(true)48 .case(false, func1)49 .case(true, func2)50 .test();51 assert.ok(!func1.called);52 assert.ok(func2.called);53});54test("calls function for matched boolean (false)", () => {55 const func1 = call();56 const func2 = call();57 check(true)58 .case(true, func1)59 .case(false, func2)60 .test();61 assert.ok(func1.called);62 assert.ok(!func2.called);63});64test("calls function for matched regexp", () => {65 const func1 = call();66 const func2 = call();67 check("hello")68 .case(/ll/, func1)69 .case("hello", func2)70 .test();71 assert.ok(func1.called);72 assert.ok(!func2.called);73});74test("calls function for matched null", () => {75 const func1 = call();76 const func2 = call();77 check(null)78 .case(null, func1)79 .case("hello", func2)80 .test();81 assert.ok(func1.called);82 assert.ok(!func2.called);83});84test("calls function for matched undefined", () => {85 const func1 = call();86 const func2 = call();87 check(undefined)88 .case(undefined, func1)89 .case("hello", func2)90 .test();91 assert.ok(func1.called);92 assert.ok(!func2.called);93});94test("calls several matching functions when stop is false", () => {95 const func1 = call();96 const func2 = call();97 const func3 = call();98 check("hello")99 .case(/ll/, func1, false)100 .case("hello", func2, false)101 .case(3, func3, false)102 .test();103 assert.ok(func1.called);104 assert.ok(func2.called);105 assert.ok(!func3.called);106});107test("calls function for conditions array", () => {108 const func1 = call();109 const func2 = call();110 check("hello")111 .case([/ll/, "hello"], func1)112 .case("hello", func2)113 .test();114 assert.ok(func1.called);115 assert.ok(!func2.called);116});117test("calls input function with value", () => {118 const func = call();119 check(1234)120 .case(1234, func)121 .test();122 assert.equal(func.input, 1234);123});124test("calls input function with value (input as function)", () => {125 const func = call();126 check(() => 1234)127 .case(1234, func)128 .test();129 assert.equal(func.input, 1234);130});131test("calls input function and compare its value", () => {132 const func1 = call();133 const func2 = call();134 check(() => 1)135 .case(1, func1)136 .case(2, func2)137 .test();138 assert.ok(func1.called);139 assert.ok(!func2.called);140});141test("don't call function for unmatched conditions array", () => {142 const func1 = call();143 const func2 = call();144 check("asdf")145 .case([/ll/, "hello"], func1)146 .case("hello", func2)147 .test();148 assert.ok(!func1.called);149 assert.ok(!func2.called);150});151test("don't call function when types are different", () => {152 const func = call();153 check("1")154 .case(1, func)155 .test();156 assert.ok(!func.called);157});158test("calls default function when nothing matches", () => {159 const func1 = call();160 const func2 = call();161 check("1")162 .case(1, func1)163 .test(func2);164 assert.ok(!func1.called);165 assert.ok(func2.called);166 assert.equal(func2.input, "1")167});168test("calls default function without case", () => {169 const func = call();170 check(1234)171 .test(func);172 assert.ok(func.called);173 assert.equal(func.input, 1234)...

Full Screen

Full Screen

局部变量.py

Source:局部变量.py Github

copy

Full Screen

...23# 函数内部可以再次定义函数, 执行需要被调用24# def func1():25# print('alex')26#27# def func2():28# print('eric')29#30# func2()31# func1()32#33# age = 1934# def func1():35# age = 7336# def func2():37# print(age)38# func2()39# func1()40#41# age = 1942#43# def func1():44# def func2():45# print(age)46# age = 7347# func2()48# func1()49#50# func1函数里面其实没有重新创建一个值age, 而是对全局变量age操作修改了51# age = 1952# def func1():53# global age54# def func2():55# print(age)56# age = 7357# func2()58# func1()59# print(age)60#61# age = 1862#63# def func1():64# age = 7365# def func2():66# print(age)67# return 66668#69# va1 = func1()70# print(va1)71# 代码定义完成之后,作用域已经生产,作用域链向上查找72#73# age = 1874#75# def func1():76# age = 7377# def func2():78# print(age)79#80# return func281#82# va1 = func1()...

Full Screen

Full Screen

056_函数的嵌套.py

Source:056_函数的嵌套.py Github

copy

Full Screen

...63. 函数名本质上是一个变量名,表示的是一个内存地址7"""8import random9def func1():10 def func2(): # 嵌套函数,局部变量11 print("func2")12 func2() # 局部的东西,一般都是在局部自己访问和使用13func1()14def func1():15 print("func1: 123")16 def func2():17 print("func2: 456")18 def func3():19 print("func3: 789")20 print("func2: 1")21 func3()22 print("func2: 2")23 print("func1: 3")24 func2()25 print("func1: 4")26func1()27def func1():28 def inner(*args):29 print("inner: 123")30 print(args)31 print(inner)32 print("inner id is:", format(id(inner), "x"))33 return inner34b1 = func1()35print(b1)36b1 = func1()37print(b1)38print("*" * 20)39# 代理模式40def func1(an):41 print(an)42 an()43def func2():44 print("func2")45# func1(2)46func1(func2) # 实参可以是一个函数47# 全局函数和全局函数的变量的id不变,但是内嵌函数的id各不相同,表示每次调用时都产生新的内嵌函数对象48print("*" * 30)49def func1():50 a = [1, 2, 3, 4]51 # a = 252 lst = [random.randint(1, 10) for i in range(random.randint(4, 10))]53 print(f"{lst=}'s id: ", id(lst))54 def func2():55 print("func1's id: ", id(func1), "func2's id: ", id(func2))56 func2()57for i in range(random.randint(1, 20)):...

Full Screen

Full Screen

user-api.js

Source:user-api.js Github

copy

Full Screen

...9 paramStr = "/?" + paramStr.substr(1);10 $http.get(api.userUri + paramStr).then(function(response) {11 func1(response.data);12 }, function(response) {13 if(func2) func2(response);14 });15 };16 api.queryUser = function(query, func1, func2) {17 $http.get(api.userUri +"/"+ query).then(function(response) {18 func1(response.data);19 }, function(response) {20 if(func2) func2(response);21 });22 };23 api.updateUser = function(query, func1, func2) {24 $http.put(api.userUri, query).then(function(response) {25 func1(response.data);26 }, function(response) {27 if(func2) func2(response);28 });29 };30 api.deleteUser = function(id, func1, func2) {31 paramStr = "/" +id;32 $http.delete(api.userUri+paramStr).then(function(response) {33 func1(response.data);34 }, function(response) {35 if(func2) func2(response);36 });37 };38 api.addUser = function(query, func1, func2) {39 $http.post(api.userUri, query).then(function(response) {40 func1(response.data);41 }, function(response) {42 if(func2) func2(response);43 });44 }45 root.UserApi = api;...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.func2();3wpt.func1();4module.exports.func1 = function() {5 console.log('func1');6};7module.exports.func2 = function() {8 console.log('func2');9};10var wpt = require('wpt');11wpt.func2();12wpt.func1();13exports.func1 = function() {14 console.log('func1');15};16exports.func2 = function() {17 console.log('func2');18};19var wpt = require('wpt');20wpt.func2();21wpt.func1();22module.exports = {23 func1: function() {24 console.log('func1');25 },26 func2: function() {27 console.log('func2');28 }29};30var wpt = require('wpt');31wpt.func2();32wpt.func1();33module.exports = {34 func1: function() {35 console.log('func1');36 },37 func2: function() {38 console.log('func2');39 }40};41var wpt = require('wpt');42wpt.func2();43wpt.func1();44exports = {45 func1: function() {46 console.log('func1');47 },48 func2: function() {49 console.log('func2');50 }51};52var wpt = require('wpt

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('webpagetest');2var wpt = new WebPageTest('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef');3wpt.runTest(url, function(err, data) {4 if (err) return console.error(err);5 console.log('Test submitted to WebPageTest for %s', url);6 console.log('Test ID: %s', data.data.testId);7});8var wpt = require('webpagetest');9var wpt = new WebPageTest('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef');10wpt.runTest(url, function(err, data) {11 if (err) return console.error(err);12 console.log('Test submitted to WebPageTest for %s', url);13 console.log('Test ID: %s', data.data.testId);14});15var wpt = require('webpagetest');16var wpt = new WebPageTest('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef');17wpt.runTest(url, function(err, data) {18 if (err) return console.error(err);19 console.log('Test submitted to WebPageTest for %s', url);20 console.log('Test ID: %s', data.data.testId);21});22var wpt = require('webpagetest');23var wpt = new WebPageTest('www.webpagetest.org', 'A.1234567890abcdef1234567890abcdef');24wpt.runTest(url, function(err, data) {25 if (err) return console.error(err);26 console.log('Test submitted to WebPageTest for %s', url);27 console.log('Test ID: %s', data.data.testId);28});29var wpt = require('webpagetest

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('./wpt');2wpt.func2();3exports.func2 = function() {4 console.log("func2");5}6exports.func1 = function() {7 console.log("func1");8}9var wpt = require('./wpt');10var wpt = require('./wpt').func1();11var wpt = require('./wpt').func2();12var wpt = require('./wpt');13wpt.func1();14wpt.func2();15var wpt = require('./wpt');16var wpt = require('./wpt').func1;17var wpt = require('./wpt').func2;18var wpt = require('./wpt');19var wpt = require('./wpt').func1;20var wpt = require('./wpt').func2;21wpt.func1();22wpt.func2();23var wpt = require('./wpt');24var wpt = require('./wpt').func1();25var wpt = require('./wpt').func2();26wpt.func1();27wpt.func2();28var wpt = require('./wpt');

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.func2('arg1', 'arg2', function(err, data) {3 console.log(data);4});5module.exports.func2 = function(arg1, arg2, callback) {6 var data = 'data';7 callback(null, data);8};

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2var test = new wpt();3test.func2(function(err, data) {4 console.log(data);5});6var wpt = require('wpt');7var test = new wpt();8test.func1(function(err, data) {9 console.log(data);10});11var wpt = require('wpt');12var test = new wpt();13test.func3(function(err, data) {14 console.log(data);15});16var wpt = require('wpt');17var test = new wpt();18test.func4(function(err, data) {19 console.log(data);20});21var wpt = require('wpt');22var test = new wpt();23test.func5(function(err, data) {24 console.log(data);25});26var wpt = require('wpt');27var test = new wpt();28test.func6(function(err, data) {29 console.log(data);30});31var wpt = require('wpt');32var test = new wpt();33test.func7(function(err, data) {34 console.log(data);35});36var wpt = require('wpt');37var test = new wpt();38test.func8(function(err, data) {39 console.log(data);40});41var wpt = require('wpt');42var test = new wpt();43test.func9(function(err, data) {44 console.log(data);45});46var wpt = require('wpt');47var test = new wpt();48test.func10(function(err, data) {49 console.log(data);50});

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt');2wpt.func2();3exports.func2 = function() {4 console.log('func2');5}6set NODE_PATH=C:\Users\user\wpt;C:\Users\user\test

Full Screen

Using AI Code Generation

copy

Full Screen

1var wpt = require('wpt.js');2wpt.func2();3 throw err;4 at Function.Module._resolveFilename (module.js:338:15)5 at Function.Module._load (module.js:280:25)6 at Module.require (module.js:364:17)7 at require (module.js:380:17)8 at Object.<anonymous> (/home/username/test.js:1:13)9 at Module._compile (module.js:456:26)10 at Object.Module._extensions..js (module.js:474:10)11 at Module.load (module.js:356:32)12 at Function.Module._load (module.js:312:12)13 at Function.Module.runMain (module.js:497:10)14var wpt = require('./wpt.js');

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 wpt 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