-- GHDL driver - xml commands -- Copyright (C) 2016 Tristan Gingold -- -- GHDL is free software; you can redistribute it and/or modify it under -- the terms of the GNU General Public License as published by the Free -- Software Foundation; either version 2, or (at your option) any later -- version. -- -- GHDL is distributed in the hope that it will be useful, but WITHOUT ANY -- WARRANTY; without even the implied warranty of MERCHANTABILITY or -- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- for more details. -- -- You should have received a copy of the GNU General Public License -- along with GCC; see the file COPYING. If not, write to the Free -- Software Foundation, 59 Temple Place - Suite 330, Boston, MA -- 02111-1307, USA. with Ada.Text_IO; use Ada.Text_IO; with GNAT.OS_Lib; use GNAT.OS_Lib; with Types; use Types; with Name_Table; use Name_Table; with Nodes_Meta; use Nodes_Meta; with Files_Map; with Disp_Tree; use Disp_Tree; with Ghdlprint; use Ghdlprint; with Libraries; with Errorout; use Errorout; with Iirs; use Iirs; with Ghdlmain; use Ghdlmain; with Ghdllocal; use Ghdllocal; package body Ghdlxml is procedure Disp_Iir (Id : String; N : Iir); -- Try to keep line length below that number. Max_Line_Len : constant Natural := 80; -- Number of space by indentation level. Indent_Size : constant Natural := 2; -- Current indentation level. Indent : Natural; -- Current column. Col : Natural; -- Low-level display routines. Consider line length, and handle -- indentation. Only use these routines to display content. -- Display indentation. procedure Put_Indent is Blanks : constant String (1 .. Indent_Size * Indent) := (others => ' '); begin pragma Assert (Col = 0); Put (Blanks); Col := Indent_Size * Indent; end Put_Indent; procedure Put_Stag (Name : String) is begin Put_Indent; Put ('<'); Put (Name); Col := Col + 1 + Name'Length; end Put_Stag; procedure Put_Stag_End is begin Put ('>'); New_Line; Col := 0; Indent := Indent + 1; end Put_Stag_End; procedure Put_Empty_Stag_End is begin Put ("/>"); New_Line; Col := 0; end Put_Empty_Stag_End; procedure Put_Etag (Name : String) is begin Indent := Indent - 1; Put_Indent; Put (""); Put (Name); Put (">"); New_Line; Col := 0; end Put_Etag; procedure Put_Attribute (Attr : String; Value : String) is -- Number of characters to be displayed. Len : constant Natural := 4 + Attr'Length + Value'Length; begin if Col + Len >= Max_Line_Len and then Indent * Indent_Size + Len < Max_Line_Len then New_Line; Col := 0; Put_Indent; end if; Put (' '); Put (Attr); Put ("="""); Put (Value); Put ('"'); Col := Col + Len; end Put_Attribute; -- Espace special characters for XML. -- -- According to: http://www.w3.org/TR/REC-xml/#NT-AttValue -- -- [10] AttValue ::= '"' ([^<&"] | Reference)* '"' -- | "'" ([^<&'] | Reference)* "'" -- [67] Reference ::= EntityRef | CharRef -- [66] CharRef ::= '' [0-9]+ ';' -- | '' [0-9a-fA-F]+ ';' function To_XML (Str : String) return String is To_Hex : constant array (0 .. 15) of Character := "0123456789abcdef"; -- The escape sequence uses 6 characters. Res : String (1 .. 6 * Str'Length); Idx : Positive; C : Character; C_Pos : Natural; begin Idx := Res'First; for I in Str'Range loop C := Str (I); case C is when '<' | '
from pathod import utils
from mitmproxy.test import tutils
def test_membool():
m = utils.MemBool()
assert not m.v
assert m(1)
assert m.v == 1
assert m(2)
assert m.v == 2
def test_data_path():
tutils.raises(ValueError, utils.data.path, "nonexistent")