Skip to content

Commit b0a03f5

Browse files
committed
Replaced has_key() calls with get(); fixed some typos. Note: not all assertions are passed!
1 parent ac92af1 commit b0a03f5

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

Demos/Demo25/fmMain.pas

+18-18
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ procedure TMain.btnTestIntegersClick(Sender: TObject);
105105
// check that operation did not change the content of operands.
106106
Assert(Integer(a) = 2);
107107
Assert(Integer(b) = 3);
108-
// now with a litteral
108+
// now with a literal
109109
c := a + b + 1;
110110
Assert( Integer(c) = 6 );
111111
c := a + 1 + b;
@@ -116,7 +116,7 @@ procedure TMain.btnTestIntegersClick(Sender: TObject);
116116
// substraction
117117
c := b - a;
118118
Assert( Integer(c) = 1 );
119-
// now with a litteral
119+
// now with a literal
120120
c := b - a - 1;
121121
Assert( Integer(c) = 0 );
122122
c := b - 1 - a;
@@ -127,7 +127,7 @@ procedure TMain.btnTestIntegersClick(Sender: TObject);
127127
// multiplication
128128
c := a * b;
129129
Assert( Integer(c) = 6 );
130-
// now with a litteral
130+
// now with a literal
131131
c := a * b * 2;
132132
Assert( Integer(c) = 12 );
133133
c := a * 2 * b;
@@ -302,7 +302,7 @@ procedure TMain.btnTestFloatsClick(Sender: TObject);
302302
// check that operation did not change the content of operands.
303303
Assert(Double(a) = dbl_a);
304304
Assert(Double(b) = dbl_b);
305-
// now with a litteral
305+
// now with a literal
306306
c := a + b + 1;
307307
Assert( Double(c) = (dbl_a+dbl_b+1) );
308308
c := a + 1 + b;
@@ -313,7 +313,7 @@ procedure TMain.btnTestFloatsClick(Sender: TObject);
313313
// substraction
314314
c := b - a;
315315
Assert( Double(c) = (dbl_b - dbl_a) );
316-
// now with a litteral
316+
// now with a literal
317317
c := b - a - 1;
318318
Assert( Double(c) = (dbl_b-dbl_a-1) );
319319
c := b - 1 - a;
@@ -325,7 +325,7 @@ procedure TMain.btnTestFloatsClick(Sender: TObject);
325325
c := a * b;
326326
dbl_c := dbl_a * dbl_b;
327327
Assert( Double(c) = dbl_c );
328-
// now with a litteral
328+
// now with a literal
329329
c := a * b * 2;
330330
dbl_c := dbl_a * dbl_b * 2;
331331
Assert( Double(c) = dbl_c );
@@ -427,7 +427,7 @@ procedure TMain.btnTestStringsClick(Sender: TObject);
427427
// check that operation did not change the content of operands.
428428
Assert(String(a) = 'abc');
429429
Assert(String(b) = 'def');
430-
// now with a litteral
430+
// now with a literal
431431
c := a + b + '!';
432432
Assert( String(c) = 'abcdef!' );
433433
c := a + '!' + b;
@@ -583,7 +583,7 @@ procedure TMain.btnTestSequencesClick(Sender: TObject);
583583
// check that operation did not change the content of operands.
584584
Assert(String(a) = '[1, 2, 3]');
585585
Assert(String(b) = '[4, 5, 6]');
586-
// now with a litteral: note that with D6 SP1, we can't concatenate a custom variant with an var array of variants
586+
// now with a literal: note that with D6 SP1, we can't concatenate a custom variant with a var array of variants
587587
c := a + b + VarPythonCreate(['Hello', 'World!', 3.14]);
588588
Assert( String(c) = '[1, 2, 3, 4, 5, 6, u''Hello'', u''World!'', 3.1400000000000001]' );
589589
c := a + VarPythonCreate(['Hello', 'World!', 3.14]) + b;
@@ -642,7 +642,7 @@ procedure TMain.btnTestSequencesClick(Sender: TObject);
642642

643643
// sequence methods:
644644
c := b + a;
645-
c.sort(); // note that you must you the parenthesis to distinguish the call between a method or a property.
645+
c.sort(); // note that you must use the parenthesis to distinguish the call between a method or a property.
646646
Assert( c = (a+b) );
647647

648648
c := NewPythonList; // facility for building sequences
@@ -770,8 +770,8 @@ procedure TMain.btnTestMappingsClick(Sender: TObject);
770770
Assert( VarIsSame(c, a) ); // checks if 2 variants share the same Python object.
771771

772772
// dict methods
773-
Assert( Boolean(a.has_key(string('a'))) );
774-
Assert( not Boolean(a.has_key('abc')) );
773+
Assert( Boolean(a.get(string('a'))) );
774+
Assert( not Boolean(a.get('abc')) );
775775
keys := a.keys();
776776
keys.sort();
777777
Assert( keys = VarPythonCreate(VarArrayOf(['a', 'b', 'c'])));
@@ -780,7 +780,7 @@ procedure TMain.btnTestMappingsClick(Sender: TObject);
780780
Assert( values = VarPythonCreate(VarArrayOf([1, 2, 3])));
781781
c := a;
782782
c.DeleteItem(string('a'));
783-
Assert( not Boolean(c.has_key(string('a'))) );
783+
Assert( not Boolean(c.get(string('a'))) );
784784

785785
// test string values
786786
a := NewPythonDict;
@@ -831,7 +831,7 @@ procedure TMain.btnTestDatesClick(Sender: TObject);
831831
Assert( b.GetItem(6) = a.GetItem(6) );
832832
Assert( b.GetItem(7) = a.GetItem(7) );
833833
// don't test the 9th item of the tuple, because it's the daylight saving,
834-
// and it's not computed by the Python for Delphi.
834+
// and it's not computed by Python for Delphi.
835835
//Assert( b.GetItem(8) = a.GetItem(8) );
836836

837837
_date2 := b;
@@ -986,7 +986,7 @@ procedure TMain.btnTestObjectsClick(Sender: TObject);
986986
Assert( VarIsPythonModule(_main) );
987987
Assert( VarIsPythonModule(SysModule) );
988988
Assert( Import('sys').version = SysModule.version );
989-
Assert( Boolean(SysModule.modules.has_key(GetPythonEngine.ExecModule)) ); // if __main__ in sys.modules
989+
Assert( Boolean(SysModule.modules.get(GetPythonEngine.ExecModule)) ); // if __main__ in sys.modules
990990
Assert( VarIsSameType(_main, SysModule) );
991991
Assert( _type(_main).__name__ = 'module');
992992
Assert( BuiltinModule.type(_main).__name__ = 'module');
@@ -1013,7 +1013,7 @@ procedure TMain.btnTestObjectsClick(Sender: TObject);
10131013
Assert( not VarIsSubclassOf(_main.Foo, _main.Bar) );
10141014
Assert( VarIsInstanceOf(_main.b, _main.Foo) );
10151015
Assert( not VarIsInstanceOf(_main.f, _main.Bar) );
1016-
Assert( VarIsTrue( BuiltinModule.vars(_main).has_key(string('f')) ) );
1016+
Assert( VarIsTrue( BuiltinModule.vars(_main).get(string('f')) ) );
10171017
Assert( VarIsTrue( BuiltinModule.dir(_main).Contains(string('f')) ) );
10181018

10191019
f := _main.Foo(); // new instance of class Foo
@@ -1037,10 +1037,10 @@ procedure TMain.btnTestObjectsClick(Sender: TObject);
10371037
Log('Test -> a, b, c : ' + a.Value + ', ' + b.Value + ', ' + c.Value);
10381038
// cascading calls
10391039
Assert( f.GetSelf().GetSelf().GetSelf().GetSelf().GetValue() = _main.f.GetValue() );
1040-
Assert( Boolean(f.__dict__.has_key('Value')) );
1040+
Assert( Boolean(f.__dict__.get('Value')) );
10411041
Assert( VarIsTrue( BuiltinModule.hasattr(f, 'Value') ) );
10421042
_str := 'Value';
1043-
Assert( Boolean(f.__dict__.has_key(_str)) ); // check with a string var
1043+
Assert( Boolean(f.__dict__.get(_str)) ); // check with a string var
10441044
Assert( Boolean( BuiltinModule.hasattr(f, _str) ) );
10451045
val := f.Value;
10461046
f.Add(f); // passing itself as an argument
@@ -1119,7 +1119,7 @@ procedure TMain.btnTestObjectsClick(Sender: TObject);
11191119
Assert( _myModule.Add(2, 2) = 4 );
11201120
// delete module var f
11211121
_main.__dict__.DeleteItem(string('f'));
1122-
Assert( _main.__dict__.has_key(string('f')) = False );
1122+
Assert( _main.__dict__.get(string('f')) = False );
11231123
// open a file using Python
11241124
if FileExists('MyModule.py') then
11251125
begin

0 commit comments

Comments
 (0)