code: def test_queue():
      q = glir.GlirQueue()
      parser = glir.GlirParser()
  
      # Test adding commands and clear
      N = 5
      for i in range(N):
          q.command("FOO", "BAR", i)
      cmds = q.clear()
      for i in range(N):
          assert cmds[i] == ("FOO", "BAR", i)
  
      # Test filter 1
      cmds1 = [
          ("DATA", 1),
          ("SIZE", 1),
          ("FOO", 1),
          ("SIZE", 1),
          ("FOO", 1),
          ("DATA", 1),
          ("DATA", 1),
      ]
      cmds2 = [c[0] for c in q._shared._filter(cmds1, parser)]
      assert cmds2 == ["FOO", "SIZE", "FOO", "DATA", "DATA"]
  
      # Test filter 2
      cmds1 = [
          ("DATA", 1),
          ("SIZE", 1),
          ("FOO", 1),
          ("SIZE", 2),
          ("SIZE", 2),
          ("DATA", 2),
          ("SIZE", 1),
          ("FOO", 1),
          ("DATA", 1),
          ("DATA", 1),
      ]
      cmds2 = q._shared._filter(cmds1, parser)
      assert cmds2 == [
          ("FOO", 1),
          ("SIZE", 2),
          ("DATA", 2),
          ("SIZE", 1),
          ("FOO", 1),
          ("DATA", 1),
          ("DATA", 1),
      ]
  
      # Define shader
      shader1 = """
          precision highp float;uniform mediump vec4 u_foo;uniform vec4 u_bar;
          """.strip().replace(
          ";", ";\n"
      )
      # Convert for desktop
      shader2 = glir.convert_shader("desktop", shader1)
      assert "highp" not in shader2
      assert "mediump" not in shader2
      assert "precision" not in shader2
  
      # Convert for es2
      shader3 = glir.convert_shader("es2", shader2)
      # make sure precision float is still in the shader
      # it may not be the first (precision int might be there)
      assert "precision highp float;" in shader3
      # precisions must come before code
      assert shader3.startswith("precision")
  
      # Define shader with version number
      shader4 = """
          #version 100; precision highp float;uniform mediump vec4 u_foo;uniform vec4 u_bar;
          """.strip().replace(
          ";", ";\n"
      )
      shader5 = glir.convert_shader("es2", shader4)
      assert "precision highp float;" in shader5
      # make sure that precision is first (version is removed)
      # precisions must come before code
      assert shader3.startswith("precision")
  
file_path: vispy/vispy/gloo/tests/test_glir.py
imports: import json
  import tempfile
  from unittest import mock
  from vispy import config
  from vispy.app import Canvas
  from vispy.gloo import glir
  from vispy.testing import requires_application, requires_pyopengl, run_tests_if_main
  import numpy
label_desc: Use image node_id 1 for calling a global function with example usage: test_queue() without return types