-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Stdlib] Add
PythonObject.__contains__
Signed-off-by: rd4com <[email protected]>
- Loading branch information
Showing
6 changed files
with
109 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# ===----------------------------------------------------------------------=== # | ||
# Copyright (c) 2024, Modular Inc. All rights reserved. | ||
# | ||
# Licensed under the Apache License v2.0 with LLVM Exceptions: | ||
# https://llvm.org/LICENSE.txt | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# ===----------------------------------------------------------------------=== # | ||
# XFAIL: asan && !system-darwin | ||
# RUN: %mojo %s | ||
|
||
from python import Python, PythonObject | ||
from testing import assert_equal, assert_false, assert_raises, assert_true | ||
|
||
|
||
def test_PyObject_HasAttrString(inout python: Python): | ||
var Cpython_env = python.impl._cpython | ||
|
||
var the_object = PythonObject(0) | ||
var result = Cpython_env[].PyObject_HasAttrString( | ||
the_object.py_object, "__contains__" | ||
) | ||
assert_equal(0, result) | ||
|
||
the_object = PythonObject([1, 2, 3]) | ||
result = Cpython_env[].PyObject_HasAttrString( | ||
the_object.py_object, "__contains__" | ||
) | ||
assert_equal(1, result) | ||
_ = the_object | ||
|
||
|
||
def main(): | ||
# initializing Python instance calls init_python | ||
var python = Python() | ||
test_PyObject_HasAttrString(python) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters