code: def test_uniform(self):
      # Text array unoforms
      program = Program("uniform float A[10];", "foo")
      assert ("uniform_array", "float", "A") in program.variables
      assert len(program.variables) == 11  # array plus elements
      self.assertRaises(
          ValueError, program.__setitem__, "A", np.ones((9, 1))
      )
      program["A"] = np.ones((10, 1))
      program["A[0]"] = 0
      assert "A[0]" in program._user_variables
      assert "A[0]" not in program._pending_variables
  
      # Init program
      program = Program(
          "uniform float A;", "uniform float A; uniform vec4 B;"
      )
      assert ("uniform", "float", "A") in program.variables
      assert ("uniform", "vec4", "B") in program.variables
      assert len(program.variables) == 2
  
      # Set existing uniforms
      program["A"] = 3.0
      assert isinstance(program["A"], np.ndarray)
      assert program["A"] == 3.0
      assert "A" in program._user_variables
      #
      program["B"] = 1.0, 2.0, 3.0, 4.0
      assert isinstance(program["B"], np.ndarray)
      assert all(
          program["B"] == np.array((1.0, 2.0, 3.0, 4.0), np.float32)
      )
      assert "B" in program._user_variables
  
      # Set non-existent uniforms
      program["C"] = 1.0, 2.0
      assert program["C"] == (1.0, 2.0)
      assert "C" not in program._user_variables
      assert "C" in program._pending_variables
  
      # Set samplers
      program.set_shaders(
          """uniform sampler1D T1;
                              uniform sampler2D T2;
                              uniform sampler3D T3;""",
          "f",
      )
      program["T1"] = np.zeros((10,), np.float32)
      program["T2"] = np.zeros((10, 10), np.float32)
      program["T3"] = np.zeros((10, 10, 10), np.float32)
      assert isinstance(program["T1"], gloo.Texture1D)
      assert isinstance(program["T2"], gloo.Texture2D)
      assert isinstance(program["T3"], gloo.Texture3D)
  
      # Set samplers with textures
      tex = gloo.Texture2D((10, 10))
      program["T2"] = tex
      assert program["T2"] is tex
      program["T2"] = np.zeros((10, 10), np.float32)  # Update texture
      assert program["T2"] is tex
  
      # C should be taken up when code comes along that mentions it
      program.set_shaders(
          "uniform float A; uniform vec2 C;",
          "uniform float A; uniform vec4 B;",
      )
      assert isinstance(program["C"], np.ndarray)
      assert all(program["C"] == np.array((1.0, 2.0), np.float32))
      assert "C" in program._user_variables
      assert "C" not in program._pending_variables
  
      # Set wrong values
      self.assertRaises(
          ValueError, program.__setitem__, "A", (1.0, 2.0)
      )
      self.assertRaises(
          ValueError, program.__setitem__, "B", (1.0, 2.0)
      )
      self.assertRaises(ValueError, program.__setitem__, "C", 1.0)
  
      # Set wrong values beforehand
      program["D"] = 1.0, 2.0
      self.assertRaises(
          ValueError, program.set_shaders, "", "uniform vec3 D;"
      )
  
imports: import unittest
  import numpy
  from vispy import gloo, app
  from vispy.gloo.program import Program
  from vispy.testing import run_tests_if_main, requires_application
  from vispy.gloo.context import set_current_canvas, forget_canvas
label_desc: Use image node_id 4 for calling the ProgramTest obj's underlying member method code with example usage: obj.test_uniform() without return types