File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change 11# RUN: %PYTHON %s | FileCheck %s
22
33import gc
4+ from pathlib import Path
5+ from tempfile import NamedTemporaryFile
46from mlir .ir import *
57
68
@@ -27,6 +29,24 @@ def testParseSuccess():
2729 print (str (module ))
2830
2931
32+ # Verify successful parse from file.
33+ # CHECK-LABEL: TEST: testParseFromFileSuccess
34+ # CHECK: module @successfulParse
35+ @run
36+ def testParseFromFileSuccess ():
37+ ctx = Context ()
38+ with NamedTemporaryFile (mode = "w" ) as tmp_file :
39+ tmp_file .write (r"""module @successfulParse {}""" )
40+ tmp_file .flush ()
41+ module = Module .parse (Path (tmp_file .name ), ctx )
42+ assert module .context is ctx
43+ print ("CLEAR CONTEXT" )
44+ ctx = None # Ensure that module captures the context.
45+ gc .collect ()
46+ module .dump () # Just outputs to stderr. Verifies that it functions.
47+ print (str (module ))
48+
49+
3050# Verify parse error.
3151# CHECK-LABEL: TEST: testParseError
3252# CHECK: testParseError: <
You can’t perform that action at this time.
0 commit comments